Linux Terminal as Publisher and Subscriber

Before you start using Linux terminal as Publisher or Subscriber, You need to install MQTT Broker on Linux. Please click on following link to Install MQTT Broker on Linux machine.
Installing MQTT Broker on Linux

1)Open Linux terminal
2)Execute the Following Command to publish data on topic test

mosquitto_pub -t test -h localhost -m “Temp:10”
mosquitto_pub -t test -h localhost -m “Humi:20”

1)Open Linux terminal
2)Execute the Following Command to Subscribe topic test

mosquitto_sub -t test -h localhost


Here Broker , Publisher and Subscriber all are running on same Linux machine because of that host name is localhost. To see data Published by publisher , Please first follow the Subscriber steps and then follow the Publisher steps.

You may also like...

Leave a Reply