In this post I’ll explore how to install Mosquitto (MQTT Broker) and test it is working.
The installation is pretty easy since Mosquitto is included in main repositories.
sudo apt-get install mosquitto
Test that Mosquitto is working
To test that Mosquitto is working, we’ll be sending a simple message to the broker and see if it is working. To do so, I use the Mosquitto clients.
On the same computer, or on another (we’re talking about network, aren’t we ?), install the clients :
sudo apt-get install mosquitto-clients
Then, we will register to receive all message:
mosquitto_sub -h 192.168.1.1 -t "#" -v
Now let’s send a message to the broker from another terminal / machine:
mosquitto_pub -h 192.168.1.1 -t "test" -m "Hello world!"
You will see the message appear on the mosquitto_sub screen.
Illustration from: Pratheep P S, www.pratheep.com, https://commons.wikimedia.org/wiki/File:Mosquito-feeding.jpg