Skip to main content

MQTT server up and running in 7 simple steps

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

Popular posts from this blog

Carnivorous Island from "Life of PI"

Yann Martel described about an floating carnivorous Island for symbolizing that something seemingly good in life can turn out to be harmful, so we should keep going with our journey of life... About the carnivorous Island from movie. In the movie 'Life of PI' after PI struggles to live in the pacific with the Bengal tiger suddenly one morning Pi  found himself at a Island. After spending so many days in the middle of the sea he found himself very lucky to find a Island. After spending some time he thought might be this was the end of his suffering and he can spend rest of his life at that island. He makes h is bed on a tree and sleeps there, in the middle of the night he wakes up and find that there were dead fish in the fresh water where he took swim in the day time. While trying to understand the mystery he plucks a fruit from the same tree and peel it off and finds a human tooth inside that fruit and then he realize that it was an carnivorous Island. The...

Create Table in Liquibase

For creating table using liquibase you can use below code and add it in your liquibase file. <createTable tableName=“employee”>      <column name="id" type="int">      <constraints primaryKey="true" nullable="false"/>   </column>      <column name="first_name" type="varchar(255)"/>   <column name="last_name" type="varchar(255)"/>   <column name="username" type="varchar(255)">      <constraints unique="true" nullable="false"/>   </column> </createTable> The use is pretty simple it's the way it looks : Tag: <createTable></createTable> This is an opening/ending tag for creating a table. These tags will enclose column sub tags which will define columns for the table. Attribute:   tableName : Name of the table which you want to create. (This is a mandatory   ...

liquibase.exception.LockException: Could not acquire change log lock. Currently locked by...

liquibase.exception.LockException: Could not acquire change log lock. Currently locked by... Solution : Open your database and find the table named 'Databasechangeloglock', check the content of the Locked column. If it is set to '1' in that case the above exception will be thrown. Try setting it to '0' and set content of the 'LOCKGRANT' and 'LOCKEDBY' to (null). You might find this interesting. http://apdynamicviews.blogspot.in/2012/08/how-databasechangeloglock-and.html