The Internet of Things (IoT) is emerging as the next technology trend, with powerful and remarkable effects across the business spectrum. IoT connects to the Internet, billions of everyday devices, which range from fitness bracelets to industrial equipment. IoT is merging the physical and online worlds and providing new opportunities and challenges for enterprises, companies, governments and consumers. The Internet of Things is predicted to permeate almost every sphere and industry. Data can be collected from, practically, any conceivable source. MQTT (Message Queuing Telemetry Transport) is a machine-to-machine (M2M)/ ‘Internet of Things’ connectivity protocol. It is designed as an extremely lightweight publish/subscribe messaging transport and is useful for connections with remote locations.
Recently, I worked on MQTT based android application. This application is used to initiate/receive alerts on certain scenarios. The alerts are received in the mobile application using MQTT clients, which then influences the received MQTT message and presents it to the user in desired formats. The same MQTT message is delivered to other hardware devices which has subscribed to the same topic i.e. the same MQTT message can be received in the mobile application as well as in the hardware device. Either of them can influence the received data and present them to the client in a desired format. In certain scenarios, MQTT message has been preferred over GCM in the application mainly because of the delivery assurance that the MQTT protocol offers.
MQTT – The Lightweight IoT Protocol
MQ Telemetry Transport (MQTT), invented by Dr. Andy Stanford-Clark (IBM) and Arlen Nipper (Eurotech) in 1999, is a simple light weight protocol using publish-subscribe messaging protocol. MQTT is designed for high latency, low-bandwidth or unreliable networks. The design principle minimizes the network bandwidth and device resource requirements. This also, ensures reliability and delivery assurance to a certain extent. MQTT can also be used in mobile applications.
MQTT is now an OASIS (Organization for the Advancement of Structured Information Standards) Standard and have been implemented across a wide range of industries since the day it was invented.
One of the real-world examples, that you might have used, is the Facebook Messenger. Facebook has used aspects of MQTT in its messenger.
How does MQTT work?
For using MQTT protocol, you need a Client and a Broker.
Please refer to GitHub Libraries for a complete list of client libraries.
MQTT Broker is responsible for receiving all messages, filtering, decision making and sending messages to subscribed clients.
MQTT is based on TCP/IP, hence both client and broker is expected to have TCP/IP stack.
What are the MQTT methods?
MQTT methods are also, referred to as verbs. MQTT defines methods to indicate desired actions to be performed on identified resources. Resources can be files or the outputs of an executable, found on a server.
Methods in MQTT are:
Connect -Waits for connection to be established with the server.
Disconnect – Waits for the MQTT client to finish any work, which needs to be done and for the TCP/IP session to disconnect.
Subscribe – Requests the server to let the client subscribe to one or more topics.
Unsubscribe – Requests the server to let the client unsubscribe from one or more topics.
Publish – Returns immediately to application thread after passing request to the MQTT client.
There are a number of alternative protocols to MQTT, such as:
- Advanced Message Queuing Protocol (AMQP)
- Constrained Application Protocol (CoAP)
- Extensible Messaging Presence Protocol (XMPP)
MQTT is the protocol built for M2M and IoT which is used to provide new and revolutionary performance. It opens new areas for messaging use cases for billions of things connected through the Internet. As MQTT specializes in low-bandwidth, high-latency environments, it is considered to be an ideal protocol for machine-to-machine (M2M) communication. The MQTT design makes it appealing for the exponential emerging Internet of Things (IoT) market. Users, who are looking for a very small publish/subscribe protocol, MQTT is the best choice for them.
By Varun C,
IoT Specialist, RapidValue