MQTT glossary
Short definitions of the MQTT concepts that come up when building and debugging.
What is MQTT?
MQTT is a lightweight publish/subscribe messaging protocol for connecting devices and services. Clients exchange messages through a central broker. Its low overhead suits constrained devices and unreliable links, which is why it is common in IoT.
What is an MQTT broker?
An MQTT broker is the server at the centre of every MQTT system. It receives every published message and forwards it to the clients subscribed to that topic. It also handles authentication, retained messages and Last Will delivery. Popular brokers include Mosquitto, EMQX and HiveMQ.
What is an MQTT client?
An MQTT client is any device or application that connects to a broker to publish, subscribe, or both. Clients never connect to one another. Every message passes through the broker.
What is an MQTT topic?
A topic is the hierarchical string that addresses a message, with levels separated by slashes, for example home/livingroom/temperature. Topics are created on first use. There is no step to declare them.
What are MQTT topic wildcards (+ and #)?
The single-level wildcard + matches exactly one level, so home/+/temperature matches every room's temperature but not deeper paths. The multi-level wildcard # matches that level and everything beneath it and must be the last character, so home/# matches every topic under home. Wildcards are only valid in subscriptions, never when publishing. Test patterns in the MQTT wildcard tester.
What is publish/subscribe (pub/sub)?
Publish/subscribe is the messaging pattern MQTT is built on. A publisher sends to a topic without knowing who is listening. A subscriber receives from a topic without knowing who sent it. The broker routes between them.
What is QoS 0 in MQTT?
QoS 0, at most once, is the lowest of the three MQTT QoS levels. The message is sent once with no acknowledgement and no retry. Fine for frequent sensor readings.
What is QoS 1 in MQTT?
QoS 1, at least once, guarantees the message arrives, but it can arrive more than once. The sender resends until it receives a PUBACK.
What is QoS 2 in MQTT?
QoS 2, exactly once, is the strongest and slowest guarantee. A four-step handshake delivers the message once and only once.
What is a retained message?
A retained message is the last message published to a topic with the retain flag set. The broker stores it and delivers it to every new subscriber, so they see the current value at once. It stays until something replaces or clears it. See how to clear retained messages.
What is the Last Will and Testament (LWT)?
The Last Will and Testament is a message a client registers with the broker when it connects. If the client disconnects unexpectedly, the broker publishes it on the client's behalf. It is the standard way to signal that a device has gone offline.
MQTT 5 vs MQTT 3.1.1
MQTT 3.1.1 is the version most deployments use. MQTT 5 adds user properties, reason codes, shared subscriptions, message expiry and topic aliases. Both are widely supported.
What is Sparkplug B?
Sparkplug B is an open specification that defines a topic structure and a protobuf payload format on top of MQTT for industrial use. Payloads are binary and need decoding to be readable.
What is keep-alive in MQTT?
Keep-alive is an interval, agreed at connection time, within which the client must send some packet. If nothing else is being sent, it sends a PINGREQ. If the broker hears nothing for 1.5 times the interval, it treats the client as disconnected and publishes its Last Will.
What are clean and persistent sessions?
A session is the broker's memory of a client, its subscriptions and queued messages. A clean session is discarded on disconnect. A persistent session keeps subscriptions and queues QoS 1 and 2 messages until the client returns. MQTT 5 replaces the flag with a session expiry interval. See the MQTT cheat sheet.
Frequently asked questions
What is MQTT?
MQTT is a lightweight publish/subscribe messaging protocol for connecting devices and services over a network. Clients exchange messages through a central broker, which makes it well suited to IoT, sensors, and low-bandwidth or unreliable connections.
What is an MQTT broker?
An MQTT broker is the server that sits between all MQTT clients. It receives every published message, matches it against active subscriptions, and forwards it to the clients that subscribed to the matching topic. Common brokers include Mosquitto, EMQX, and HiveMQ.
What is QoS in MQTT?
QoS (Quality of Service) is the delivery guarantee attached to a message. QoS 0 delivers at most once with no acknowledgement, QoS 1 guarantees at least once delivery (possible duplicates), and QoS 2 guarantees exactly once delivery using a four-step handshake.
What is a retained message in MQTT?
A retained message is the last message published to a topic with the retain flag set. The broker stores it and immediately delivers it to any client that subscribes to that topic afterwards, so new subscribers see the most recent value without waiting for the next publish.
See the ESP32 and Home Assistant guides, or download MQTT Viewer to watch real traffic.
MQTT Viewer is free and open source, and runs on macOS, Windows and Linux.
Download MQTT Viewer