Frage

I am trying to use the MQTT javascript client from Paho. I see a example from HiveMQ, you can check it here - - http://www.hivemq.com/demos/websocket-client/

It seems to be working, however when I set the host as: test.mosquitto.org:1883, which is a mqtt broker service at mosquitto, it fails.

When I tried to connect to this mosquitto service, it gives me a error on connection - connect failed: AMQJS0007E, Socket error: undefined.

War es hilfreich?

Lösung

Mosquitto does not support MQTT over WebSockets out of the box. So Roger is using lighttpd with the mod_websocket module to forward.

This means that the port will be port 80 not 1883

But having just had a quick look at http://test.mosquitto.org/ws.html it seams that the lighttpd instance may be down at the moment as the demo is not working.

If you want to run your own local copy of mosquitto for testing there is a link on that page with instructions on how to build mod_websocket for lighttpd or a ubuntu ppa to download it from.

EDIT:

Mosquitto now includes WesbSocket support built in, but you will need to add an extra listener to enable it, e.g.

listener 8883
protocol websockets

Andere Tipps

As hardillb says, you need to use port 80. The full url you should use is

ws://test.mosquitto.org/mqtt

If you are using m2m.eclipse.org as Andy suggests (which is actually using apache with websockets support) then you should use

ws://m2m.eclipse.org/ws

You could try the same thing against m2m.eclipse.org which I think has websocket support switched on via lighthttpd as well.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top