Install Mosquitto with Websockets on Mint

Here are my notes on how to retrieve, compile and configure Mosquitto with Websockets on Mint 18. I would imagine though this could work on Ubuntu or other Mint versions.

sudo apt-get install build-essential libc-ares-dev uuid-dev

sudo apt-get install libwebsockets-dev

Get the version that you prefer by changing the tar.gz file name below

tar xvzf mosquitto-1.4.10.tar.gz
cd mosquitto-1.4.10/


# Build with websockets support on the broker.

sudo make install

sudo adduser mosquitto
sudo mosquitto_passwd -c /etc/mosquitto/pwfile mosquitto

sudo /etc/mosquitto/mosquitto.conf

# =================================================================
user mosquitto

# =================================================================
listener 1883
protocol mqtt

listener 9001
protocol websockets

# =================================================================
persistence true
persistence_location /var/lib/mosquitto/

# =================================================================
log_dest syslog

log_type error
log_type warning
log_type notice
log_type information

sudo /sbin/ldconfig
sudo mosquitto -c /etc/mosquitto/mosquitto.conf -v


Test the setup by using two additional shells one for each of the two commands below
mosquitto_sub -h localhost -t “greetings” -v
mosquitto_pub -h localhost -t “greetings” -m “hello”

NB The commands about do not test the websockets on port 9001 for which you would need to develop a Javascript test program or similar

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.