MQTT – IoT Messaging Protocol
Introduction
- MQTT is a standard messaging protocol for IoT( Internet Of Things).
- It follows the OASIS( Organization for the Advancement of Structured Information Standards ) standards.
- It is a very lightweight pub-sub(Publish and Subscribe) messaging transport for IoT devices.
- It provides bidirectional communication.
- Encryption of messages is very easy.
- The message delivery system is very reliable.
- MQTT is used in – Logistics, smart homes, manufacturing, smart cities, and many more.
Client
- An MQTT Client is a device such as a microcontroller.
- Every client has a separate ID or name.
- The client name must be unique.
- Every Client connects to an MQTT broker over a network.
- Publisher and subscriber both are MQTT clients.
- Every client connects to a broker to talk to another client.
- No two clients can communicate without the help of a broker.
Broker
- The broker is the one that manages the communication between publisher and subscriber.
- It can be called the heart of the MQTT.
- A single broker can handle up to millions of active connections.
- It also supports session maintenance and data recovery.
- Authentication and Authorization are also done at the broker’s end.
- Every message that is published passes through a broker.
Topic/Subscription
- The topic is a string that is used for sending messages.
- The broker uses the topic to distinguish between messages, like which message is for which topic.
- Every subscriber subscribes to a topic so as to receive the messages published on that topic.
- The topic is similar to an API path in that is it can be hierarchically separated by /.
- An example of one topic is car/front/ac/temperature.
- A wildcard + symbol is used to define that any value can be fitted there.
- An example of a wildcard – car/+/ac/temperature. here in + sign can have any values like front or back.
- For defining the multi-level hierarchy # symbol is used.
- An example of a multi-level hierarchy is – car/#, it will cover anything that starts with car/.
- Topics are also known as subscriptions.
Quality Of Service (QoS)
- Quality of service means how better the communication will be.
- There are 3 QoS defined in MQTT – 0, 1, 2
- 0 means the message will be delivered without any confirmation.
- 1 means the message will be delivered at least once with confirmation.
- 2 means the message will be delivered exactly once with 4 part hand-shake.
- QoS is the best way of communication with all the security but all the slowest.
References-
- https://mqtt.org/
Still Curious? Visit my website to know more!
For more interesting Blogs Visit- Utkarsh Shukla Author
0 Comments
Add Comment
You must be logged in to post a comment.