MQTT Essentials

The Ultimate Guide to MQTT for Beginners and Experts

MQTT (Message Queuing Telemetry Transport) is the de facto data exchange protocol for IoT messaging. Standardized by OASIS and ISO, the MQTT publish/subscribe protocol provides a scalable and reliable way to connect devices over the Internet.ย 

MQTT is the most commonly used messaging protocol for the Internet of Things (IoT). MQTT stands for MQ Telemetry Transport. The protocol is a set of rules that defines how IoT devices can publish and subscribe to data over the Internet. MQTT is used for messaging and data exchange between IoT and industrial IoT (IIoT) devices, such as embedded devices, sensors, industrial PLCs, etc. The protocol is event driven and connects devices using the publish /subscribe (Pub/Sub) pattern. The sender (Publisher) and the receiver (Subscriber) communicate via Topics and are decoupled from each other. The connection between them is handled by the MQTT broker. The MQTT broker filters all incoming messages and distributes them correctly to the Subscribers.

HiveMQ wrote the book on MQTT

Youโ€™re in the right place for expert guidance and resources whether youโ€™re new to MQTT or building out your IoT platform.

Get MQTT Essentials

What is MQTT?

The MQTT protocol is the de-facto standard for IoT messaging. Standardized by OASIS and ISO, MQTT publish/subscribe protocol provides a scalable and reliable way to connect devices over the Internet. Today, MQTT is used by many companies to connect millions of devices to the Internet.

Why Companies Use MQTT

  • It requires minimal resources since it is lightweight and efficient

  • Supports bi-directional messaging between device and cloud

  • Can scale to millions of connected devices

  • Supports reliable message delivery through 3 QoS levels

  • Works well over unreliable networks

  • Security enabled, so it works with TLS and common authentication protocols

Key Features

MQTT Clients
MQTT Clients

MQTT clients publish a message to an MQTT broker and other MQTT clients subscribe to messages they want to receive. Implementations of MQTT clients typically require a minimal footprint so are well suited for deployment on small constrained devices and are very efficient in their bandwidth requirements.
HiveMQ develops a Java-based MQTT client that is available under an open source license.

MQTT Broker
MQTT Broker

MQTT brokers receive published messages and dispatch the message to the subscribing MQTT clients. An MQTT message contains a message topic that MQTT clients subscribe to and MQTT brokers use these subscription lists for determining the MQTT clients to receive the message.
HiveMQ offers a commercial and open source MQTT broker.

MQTT QoS (Quality of Service) Levels
MQTT QoS (Quality of Service) Levels

MQTT implements 3 quality of service levels for agreement between the sender and receiver:

1) At most once (0),

2) At least once (1), and

3) Exactly once (2).

These QoS levels allow for more reliable IoT applications since the underlying messaging infrastructure and adapt to unreliable network conditions.

Persistent Sessions
Persistent Sessions

MQTT allows for a persistent session between the client and the broker. This allows for sessions to persist even if the network is disconnected. Once the network is reconnected, the information to reconnect the client to the broker still exists. This is one of the key features that makes the MQTT protocol more efficient than HTTP for use over unreliable cellular networks.

Retained Messages
Retained Messages

MQTT clients that subscribe to a new topic have no insight into when to expect the first message they will receive. However, an MQTT broker can store a retained message that can be sent immediately upon a new MQTT subscription. In this case, the MQTT client will receive at least one message upon subscribing to the topic.

Last Will and Testament (LWT)
Last Will and Testament (LWT)

An MQTT client can specify to an MQTT broker a message, called the last will, that will be sent if the MQTT client ungracefully disconnects. This allows for a more graceful system wide notification that a client has been disconnected.

MQTT Basics: What is MQTT and How Does it Work?

Chapters
  • 00:00 - Introduction
  • 00:26 - What does the acronym MQTT stand for?
  • 01:07 - What does MQTT do?
  • 02:13 - Publish-Subscribe Pattern
  • 02:50 - MQTT Architecture
  • 04:50 - MQTT enables IoT
  • 05:50 - Conclusion

MQTT Basics

MQTT is the most commonly used messaging protocol for the Internet of Things (IoT). MQTT stands for MQ Telemetry Transport. The protocol is a set of rules that defines how IoT devices can publish and subscribe to data over the Internet. MQTT is used for messaging and data exchange between IoT and industrial IoT (IIoT) devices, such as embedded devices, sensors, industrial PLCs, etc. The protocol is event driven and connects devices using the publish / subscribe (Pub/Sub) pattern. The sender (Publisher) and the receiver (Subscriber) communicate via Topics and are decoupled from each other. The connection between them is handled by the MQTT broker. The MQTT broker filters all incoming messages and distributes them correctly to the Subscribers.

MQTT Features

MQTT is packed with features, such as Quality of Service (QoS) levels, persistent session and queuing messages, Retained Messages, etc.

MQTT Vs. Other IoT Protocols

Which protocol is the right choice for your IoT requirements? Check out these valuable resources.

More on MQTT

Learn more about MQTT and MQTT brokers.

MQTT Glossary

Get to Know the Key MQTT Terminologies at a Glance

Get the help you need.

Ask our experts or learn more about MQTT as you work to connect, communicate, and control your IoT data.

HiveMQ logo
Review HiveMQ on G2