Skip to content

MQTT

MQTT (MQ Telemetry Transport) is a client server messaging protocol, which is light weight (requires minimum clients and resources) and can be used to publish and subscribe data between devices to cloud, or machine to machine. MQTT is the most widely used protocol in Internet of Things (IoT). MQTT follows the OASIS standard for handling messages. The important aspect of the MQTT is that it is extremely easy to implement, and more reliable when compared to protocols such as HTTP.

You find more information on the MQTT protocol here.

Client Server - Publish/Subscribe Architecture

MQTT protocol acts as an alternative to client server model. The client server model will hold direct communications between the client and server. MQTT provides the publish subscribe model of communication, where the clients make use of a message brokers. Message brokers are servers which sends and receives the messages from the clients to required destination clients. The messages are organized as topics. A publisher when sends control message with the data to the broker, the broker distributes the message to the destination clients who ever has subscribed to the topics.

MQTT clients

Multiple clients can receive message from the broker if they have subscribed for the same topic. If there are subscribers for a message, those messages are retained by the broker, along with its corresponding Quality of Service (QoS) for the topic. Clients that subscribe to the retained message, receives the retained message immediately. MQTT uses the TCP/IP protocol for data transmission. The MQTT communication is bi-directional, and the message is decoupled by the publisher through the broker.

MQTT uses connector to set up a connection between Client and the broker. You need the following components to set up the connector to use MQTT:

  • MQTT connection – uses certification, security protocols
  • MQTT operation – uses messages to publish/subscribe from brokers using topics

Every message contains topic also referred as the subject that the broker uses to determine the authenticity of the subscribing client. Every connection to the broker is determined by three Quality of Service (QoS) levels. You can easily mention if a message gets successfully delivered from the client to the broker or from the broker to a client. However, at times there might be a possibility that nobody subscribes to the particular topic. In such cases, the broker must know how to handle the situation.