In this post I won't be talking about what MQTT server is why is and all, may be I'll write a different post for that. This post focuses on installing MQTT broker and getting it to work in 7 simple steps.
Step 1: sudo apt-get update
Step 2: sudo apt-get install mosquitto
Step 3: sudo apt-get install python-pip
Step 4: Install mosquitto module for python
> sudo python-pip install mosquitto
Step 5: Install mosquitto client
> sudo apt-get install mosquitto-clients
After executing above command you can start publisher and subscribe modules.
These publisher subscriber can use a topic and write/read data from it respectively.
Step 6: Start subscriber client
=> mosquitto_sub -h <hostname> -t <topicname> -v
> mosquitto_sub -h localhost -t testTopic -v
Step 7: Start publisher client
=> mosquitto_pub -h <hostname> -t <topicname> -m "<message>"
> mosquitto_pub -h localhost -t testTopic -m "Test Messages"
Please let me know if you find any errors while working with these steps.
References:
https://madalanarayana.wordpress.com/2014/03/25/learnings-on-publish-subscribe-mqtt-mosquitto/
http://www.hivemq.com/blog/mqtt-essentials-part-3-client-broker-connection-establishment
Comments
Post a Comment
.