Setting up an MQtt WebSocket Gateway for Raspberry Pi
BRAMLEYD 100000UYS6 Comments (11) Visits (10444)
The library allows for very rich visualisations and dashboards to be created using HTML5 with MQtt data being sent over websocket connections. It is easy to work with and performs exceptionally well.
There is one complication with this however: not all mqtt brokers support web sockets. So if you are using a broker such as Mosquitto or RSMB then in order to connect your HTML5 cilent a websocket proxy gateway is required.
In my case I'm using a low energy Raspberry Pi as a messaging hub using the Mosquitto broker. To enable websockets I have installed Lighttpd server with the nori 0428 mod_websockets gateway.
The installation was not exactly trivial - so I have documented here the steps I followed to get this working.
The base platform for the Pi is Rapbian Wheezy. The compilation steps in this procedure take a while....
Once installed, create a configuration file called websocket.conf and place it in the directory /hom
The file should have the following contents:
To start the webserver run the following command:
sudo lighttpd -D -f websocket.conf
Websocket forwarding to the local broker will now be enabled on port 80/mqtt
Test it using this useful HTML5 test client; http