vendredi 27 février 2015

How to configure mqtt.js to connect to iot.eclipse.org over websockets

Edit: My issue is now this. I can connect to iot.eclipse.org using http://ift.tt/1AB7hth, using port 80. When I connect via a browsified mqtt.js client I am getting the following error :



WebSocket connection to 'ws://iot.eclipse.org/' failed: Error during WebSocket handshake: Unexpected response code: 200



I've tried ports 8080, 8000, 1883 and 80, without any luck. Any suggestions?


------------ Original question below -----------


I want to connect with a mqtt broker using mqtt over websockets. My client will need to run in a browser.


TO achieve this I am using mqtt.js library and am following these instructions.


Everything works when running against the public broker at broker.mqttdashboard.com. However when I connect to the public brokers at iot.eclipse.org and test.mosquitto.org I get HTTP errors.


I think the problem is incorrect configuration of the client when running against the second two brokers, but I'm struggling to find any help.


Heres the configuration, is there anyone out there who can help me?



// Works fine
var options = {
host: "broker.mqttdashboard.com",
port: 8000
};

// Doesn't work
/*var options = {
host: "m2m.eclipse.org",
protocolId: 'MQIsdp',
protocolVersion: 3
};*/

// Doesn't work
/*var options = {
host: "test.mosquitto.org",
protocolId: 'mosqOtti',
protocolVersion: 3
};*/

var client = mqtt.connect(options);


Let me know if theres any more information you need!


Mark


Aucun commentaire:

Enregistrer un commentaire