Mqtt.js: WebSocket connection to 'ws://test.mosquitto.org/' failed: Error during WebSocket handshake: Unexpected response code: 200

Created on 9 Jun 2017  路  1Comment  路  Source: mqttjs/MQTT.js

I'm simply trying to use mqtt.js to connect to the test mosquitto server using the browser:

var client  = mqtt.connect('mqtt://test.mosquitto.org')

        client.on('connect', function () {
          client.subscribe('presence')
          client.publish('presence', 'Hello mqtt')
        })

When I launch my app (Angular - client side) I get the following error:

mqtt.min.js:6 WebSocket connection to 'ws://test.mosquitto.org/' failed: Error during WebSocket handshake: Unexpected response code: 200

I also tried:
var client = mqtt.connect('mqtt://broker.mqttdashboard.com');

resulted in error 301

WebSocket connection to 'ws://broker.mqttdashboard.com/' failed: Error during WebSocket handshake: Unexpected response code: 301

Is there anything I'm missing here?

>All comments

Was this page helpful?
0 / 5 - 0 ratings