Skip to content

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 the New 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 developed 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 Packets: A Comprehensive Guide

Explore MQTT control packets, the core of IoT communication. Learn their structure and types to design and test MQTT-based systems.

MQTT Broker Comparison – Which is the Best for Your IoT Application?

In-depth comparison of open-source Vs. commercial Vs. cloud MQTT brokers for IoT/IIoT devices and applications.

Creating Highly Available and Ultra-scalable MQTT Clusters

Learn how MQTT Broker Clusters are essential for high availability and scalability to solve the critical part of a messaging infrastructure.

MQTT Topic Tree & Topic Matching: Challenges and Best Practices Explained

Learn how to find matching subscriptions among millions of MQTT subscribers.

MQTT over Websockets

Learn to send and receive MQTT messages directly in a browser.

A Beginner's Guide to MQTT Brokers

Learn how to set up an MQTT broker, how to choose the right one for your IoT/IIoT use case & more with this guide.

Implementing MQTT in Java

Learn how to set up an MQTT client and a broker connection in Java.

Implementing MQTT in JavaScript

Learn how to set up an MQTT client and a broker connection in JavaScript.

Implementing MQTT in C

Learn how to set up an MQTT client and a broker connection in C.

Implementing MQTT in C Sharp

Learn how to set up an MQTT client and a broker connection in C Sharp.

Implementing MQTT in Python

Learn how to set up an MQTT client and a broker connection in Python.

15 Frequently Asked MQTT Questions

Top 15 frequently asked questions or FAQs about MQTT protocol, such as does MQTT work with Apache Kafka, does MQTT require internet, etc.

Celebrate 25 Years of MQTT with HiveMQ

Join us as we celebrate 25 years of MQTT. Enroll into our mailing list and we'll keep you updated on all of the happenings this year from MQTT awards to a fireside chat later in the year.

MQTT Glossary

Get to Know the Key MQTT Terminologies at a Glance

Apply for the MQTT Innovation Awards

The MQTT Innovation Awards recognize the outstanding achievements of leading companies and individuals leveraging the HiveMQ platform and MQTT technology across diverse industries including energy, automotive, manufacturing, transportation, logistics, and beyond.

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