MQTT (MQ Telemetry Transport) is a lightweight message protocol that provides telemetry information to clients with network limitations in a simple way. The protocol mainly uses a publish-subscribe communication pattern, which is mainly used for M2M(Machine to machine) communication and plays a crucial role in the Internet of things (IoT). The MQTT protocol is a great choice for wireless networks that may experience different levels of latency due to occasionally unreliable connections or bandwidth constraints.

This protocol was designed by Andy Stanford-Clark and Arlen Nipper in 1999 mainly for connecting sensors on oil pipelines with communications satellites, with an emphasis on minimum bandwidth usage.

Working of MQTT :

In the MQTT protocol, the connected devices are known as “clients,” which communicate with a server known as the “broker.” The broker handles the task of data transmission and communication between clients 

Whenever a client wants to distribute particular information,it publishes that information to a particular topic, then the broker sends the information to any clients that have subscribed to that topic. Any client can be a publisher, or a subscriber, or both.

Advantages of MQTT:

  1. Efficient data transmission 
  2. Quick to implement as it is a lightweight protocol
  3. Low network usage due to minimization of data packets
  4. Fast and efficient message delivery
  5. Uses very small amounts of power, which is good especially for the wireless devices
  6. Reduction of network bandwidth in communication.

Why MQTT over HTTP?

MQTT over HTTP:

MQTT HTTP
Fast as the data packet size is smallSlow as it used bigger data packet size
The connection is always open between broker and clientOpen and close the connection every time for each request
Low power consumptionHigher power consumption
Mainly useful for sending short messages.Mainly useful for sending lengthy messages.
It provides easy management for large applications.Not easy to manage for large applications

MQTT Broker:

It is a server that handles the communication between the clients. A broker can have many clients connected to it, which can publish and subscribe all the time.

MQTT Broker

Types of MQTT Brokers:

Mosquitto:

Mosquitto is a lightweight MQTT broker written in the C language. It supports TLS and there are plugins for authorization using a database, But it has some disadvantage as:

  1. It does not support clustering so it is difficult in terms of scalability.
  2. It cannot take advantage of multi-core CPUs.

RabbitMQ:

It is a very popular message broker which is written in ‘Erlang’ that supports MQTT via a plugin. It supports TLS and clustering is also fine. Authorization cannot be done using a database directly but we can create an HTTP REST wrapper over the database and that can be used for authorization. This broker supports the AMQP protocol natively but, the MQTT implementation is missing some important features such as QoS2.

VerneMQ:

It is a distributed, high-performance MQTT message broker built-in Erlang. VerneMQ can scale horizontally and vertically to support a huge number of concurrent publishers and subscribers. These subscribers can connect to any node and can also receive messages from any other node.Also, as VerneMQ is mainly written in Erlang, it is capable of working on a multi-threaded processor and also can take the benefit of multi-core processors. It is also an active community on GitHub and Docker images are also available for installation.

Eclipse Paho:

This is mainly an umbrella project for several MQTT implementations in different programming languages. It is an open-source MQTT client implementation and is also maintained by a huge community. Paho API comes with support with different languages and platforms like C/C++ , Android, Arduino, Python, Java, and Rust.To use Paho in our IoT project we just have to import the appropriate library and begin using various functions provided by the library for our requirements. There are also various GUI tools available which include RCP application, Eclipse plugin, and Java Swing application.

But there are also some disadvantages of MQTT:

  1. Slower transmit cycles compared to CoAP(Constrained Application Protocol)
  2. MQTT is not encrypted as it was not designed with security in mind. It mainly uses TLS/SSL for security encryption, which is not a lightweight protocol.
  3. It is difficult to create a global scalable network using MQTT protocol.
  4. The message receiver cannot know who sent the message if we don’t include that information in the actual message.

Conclusion:

MQTT Protocol is a lightweight and fast protocol for using especially in IoT. In IoT, the main concern is minimum battery and network bandwidth usage as the devices are wireless and run on battery, which can be achieved efficiently using MQTT.

Headquarter

4701 Patrick Henry Drive,
Bldg. 16, Suite 106, Santa Clara, California 95054
781-640-0588
sales@neovatechsolutions.com

Development Center

P3-603, Pentagon Tower,
Magarpatta City, Hadapsar, Pune, Maharashtra 411028
960-702-3233