Latest versions of mosquitto (since 1.4) include the websockets interface, but the binary download available from the website does not. So you have to download the source code and build the packet your own, last you have to configure mosquitto to use websockets.

In the following few lines I’m going to show to you how to build and configure mosquitto with websockets on a clean debian wheezy distro.

Step 1 – Let’s start preparing the build system

Step 2 – Download and build libwebsockets
Latest version of libwebsockets prevents mosquitto to be built, so I’m going to use version 1.4 of libwebsockets:

 mosquitto_mqtt
Step 3 – Download and build mosquitto 1.4.2

Edit config.mk changing the line

to
WITH_WEBSOCKETS:=yes

Step 4 – Configure mosquitto to use websockets
Add the following lines to /etc/mosquitto/mosquitto.conf in the “Default Listener” section:

So your config file should look like the following:

Step 5 – Last steps

Step 6 – Run mosquitto

Now you are ready to run your websockets application against mosquitto.
Gg1

If you’ve found useful this post, please, make a visit to my linkedin profile gg1 to help me growing my ranking.