In this case I’m going to use Mosquitto (MQTT) server behind lighttpd with mod_websocket as notifications server. Mosquitto is a lightweight MQTT server programmed in C and very easy to set up. The best advantage to use MQTT is the possibility to create publish/subscriber queues and it’s very useful when you want to have more than one notification channel. As is usual in pub/sub services we can subscribe the client to a well-defined topic or we can use a pattern to subscribe to more than one topic. The Mosquitto MQTT broker gets Websockets support. 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 Mosquitto broker! This makes using MQTT even more fun. Websocket support must be explicitly enabled when building Mosquitto, and building requires libwebsockets. Once enabled, we can add listeners with the websocket protocol. Getting Started with Node.js and MQTT. This post is contributed by Charlie Key, CEO and Co-Founder of Structure.