When I wrote about the HiveMQ MQTT broker I said it had a killer-feature: support for
Websockets. I’ll admit to have been pestering Roger
Light, creator of Mosquitto, so much that to
shut me up (I think) he’s been adding support for Websockets into the
Websocket support must be explicitly enabled when building Mosquitto, and
building requires libwebsockets.
Once enabled, we can add listeners with the websocket protocol. For
example, this mosquitto.conf provides a default MQTT listener on port 1883,
and two Websocket listeners, one with TLS, one without:
Mosquitto ACLs work for Websockets just as they do for MQTT publishes & subscribes; when accessing the broker via Websockets a different TCP transport channel is used – everthing else remains the same.
which shows messages published to the Mosquitto broker as soon as they’re
I’ve put the source to this simple example on Github, and I’ve verified it
works with Safari, Chrome, and FireFox.
Instead of writing your own Web application, you can easily use the mqtt.io
or the HiveMQ Websocket clients; configure them to use the host name and TCP port number (from the listener directive) of your Mosquitto broker.
Mosquitto with Websocket support should be with you very soon, and I hope
you’ll agree with me, that this is very good news. :-)