Six steps to install mosquitto 1.4.2 with websockets on Debian Wheezy

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

$ sudo apt-get update
$ sudo apt-get install build-essential python quilt devscripts python-setuptools python3
$ sudo apt-get install libssl-dev
$ sudo apt-get install cmake
$ sudo apt-get install libc-ares-dev
$ sudo apt-get install uuid-dev
$ sudo apt-get install daemon

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:

$ wget http://git.libwebsockets.org/cgi-bin/cgit/libwebsockets/snapshot/libwebsockets-1.4-chrome43-firefox-36.tar.gz

$ tar zxvf libwebsockets-1.4-chrome43-firefox-36.tar.gz

$ cd libwebsockets-1.4-chrome43-firefox-36

$ mkdir build

$ cd build

$ cmake ..

$ sudo make install

$ sudo ldconfig

$ cd

Step 3 – Download and build mosquitto 1.4.2

$ wget http://mosquitto.org/files/source/mosquitto-1.4.2.tar.gz

$ tar zxvf mosquitto-1.4.2.tar.gz

$ cd mosquitto-1.4.2

Edit config.mk changing the line

WITH_WEBSOCKETS:=no

to

WITH_WEBSOCKETS:=yes

$ make

$ sudo make install

$ sudo cp mosquitto.conf /etc/mosquitto

Step 4 – Configure mosquitto to use websockets

Add the following lines to /etc/mosquitto/mosquitto.conf in the “Default Listener” section:

port 1883

listener 9001

protocol websockets

So your config file should look like the following:

# =================================================================

# Default listener
# =================================================================
# IP address/hostname to bind the default listener to. If not
# given, the default listener will not be bound to a specific
# address and so will be accessible to all network interfaces.
# bind_address ip-address/host name
#bind_address
# Port to use for the default listener.
port 1883
listener 9001
protocol websockets

Step 5 – Last steps

$ sudo adduser mosquitto

$ reboot

Step 6 – Run mosquitto

$ mosquitto -c /etc/mosquitto/mosquitto.conf
Now you are ready to run your websockets application against mosquitto.

Original post: http://www.xappsoftware.com/wordpress/2015/05/18/six-steps-to-install-mosquitto-1-4-2-with-websockets-on-debian-wheezy/

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: