Installing Mosquitto MQTT broker on Raspberry Pi

Simply run

sudo apt-get install mosquitto mosquitto-clients

This will install and run mosquitto.

But if you want it to run automatically at startup then run

sudo service mosquitto start

To configure how it operates, edit the mosquitto.conf file

sudo nano /etc/mosquitto/mosquitto.conf

(ignore instructions about not editing it)

I use this to get a simple broker listening on 1883 and 9001 for websocket traffic

autosave_interval 1800
persistence true
persistence_file m2.db
persistence_location /tmp/
connection_messages true
log_timestamp true
listener 1883
protocol mqtt
listener 9001
protocol websockets

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *