Skip to main content
Version: Mosquitto 2.1

MQTT Vocabulary


There are various acknowledgements that are used within MQTT:



There is no alternative for clients (publisher and subscribers) than to connect to a broker when you are using MQTT protocol architecture. All packets must pass the broker. Each getting checked for specific properties, also the broker filters the package to figure out whom (subscribers) to forward the package to. See more

Clean Session

This parameter shows if a client wants to establish a persistent session with a broker or not. Therefore, the cleanSession parameter can have two values: “true” (Client doesn’t want to establish a persistent session. In addition, all previous persistent sessions are dismissed.) or “false”(Client wants to establish a persistent session.)

Clean Start

cleanStart = 0 In this case the server resumes communication with the client based on the state of the current session (the session is identified by the clientId). If there is no earlier session, the broker must create a new session. In case of a connection disconnectiong, the broker must store: Whether the session exists. Even though a topic has no subscriptions and therefore the session would be without real use. All subscriptions. All QoS1 or QoS2 messages that haven't been confirmed by the client yet. cleanStart = 1 In this case the broker discards any previous sessions and opens a new one.


The data is sent via the MQTT protocol. The MQTT broker receives the data, filters the data packet, and forwards it to the receiving clients. In this scenario, the receiving clients could be the radiator or humidifier. This is possible because of the efficient protocol format, and because a broker is used to decouple the sender and receiver. See more

Client ID

Most used for cleanSession. In case you have set CleanFlag=false and reconnected with the same clientId, the broker remembers the topics you have subscribed to.


The broker in return responds by sending a so-called CONNACK packet (Acknowledge connection request) and a status code. If the clean session value in a client’s CONNECT message is “true,” then the session present value in the CONNACK response will be “false.” It means that a client and broker should establish a new session and, at the same time, discard any existing one. After the CONNECT and CONNACK packet is exchanged, the connection is enabled.


See more


An MQTT broker always connects clients who want to share and clients who want to receive data.


See more


In this documentation, any device can be a client. And any client can be a publisher or subscriber.


A dupFlag indicates the duplicate of a message. See more


There is only the DUP flag available within MQTT.


The Internet Protocol (IP) is a network protocol that is widespread in computer networks and represents the basis of the Internet due to its function. The IP is the implementation of the Internet layer of the TCP/IP model. See more

Keep Alive

The MQTT keepAlive parameter identifies the maximum interval in seconds (e.g., 120, as I show in this article’s example) when a client maintains the MQTT connection but without communication (sending an MQTT packet). After the specified keepAlive parameter period is over, a client sends a PING request (PINGREQ), and a broker has to respond with a PING Response (PINGRESP). If no response follows the PING request, the client can assume the connection has disconnected. Also, the broker is waiting for the PING request. The broker must expect a PINGREQ and wait for another half of the set in the keepAlive parameter time, but then disconnect the connection for good. See more

Last Will

The lastWill message is sent by the broker on behalf of the client when a disconnect occurs without a DISCONNECT packet before the actual break-off. See more


The actual content of a message is the content of a payload. MQTT is not limited by its payload format. It delivers what the publisher is sending. This could be a value, string, JSON file, or even content of a jpg or an mp3 file. Up to 256MB. The payload does not encrypt the content. The broker simply delivers what the publisher inserts into the payload. See more


MQTT = “MQ Telemetry Transport”. The setup consists of two basic concepts: PUBLISH / SUBSCRIBE and CLIENT / BROKER. And three basic functionalities: CONNECT, PUBLISH, SUBSCRIBE See more

MQTT v.3.1.1

Most MQTT-related devices support v.3.1.1 whilst v.5.0 not. See more

MQTT v.5.0

The MQTT version 5.0 is the next development step in the evolution of MQTT. Especially interesting is the changes made to the cleanSession. Have a look here:


There is no definition of when a delivery is called a packet or message. Cedalo is using the term "packet" for any of the commands, and "message" for publishing or subscribing messages. All packets must pass the broker.

Packet ID

Unique packet identifier the broker uses to identify the packet when needed. See more


MQTT can forward and handle username and password within a sent packet. It's important that whenever a packet is not encrypted or hashed (either by implementation or TSL), the password is sent as plain text. See more


MQTT is not limited by its payload format. It delivers what the publisher is sending. The actual content of a message is the content of a payload. See more

Persistent Session

The Persistent session is active when the cleanSession flag is set to false. An active MQTT persistent session (with the cleanSession having the “false” value) is activated whenever the client disconnects ungracefully. All information that the client did not receive from the broker since the last active connection will be preserved on the broker and delivered to the client once the connection is restored. The broker resumes the client in the existing session if the clientId is the same as the disconnected client. A client will not have to resubscribe to all topics again. See more


No matter who is not answering or sending the PINGREQ or PINGRESP within the specific time interval plus another half of the very same interval, the broker or client must disconnect. When this happens, the broker sends the lastWill and testament message. If the client has created one. Within the interval, it's ok that the client and broker do not transmit messages. In fact, after this interval, the client must send a so-called PING Request packet (PINGREQ).


See more


The broker must respond with a PING Response (PINGRESP). If the connection is out of sync, and a participant is not responding - called a "half-open connection", keepAlive takes action.


See more

Pub / Sub

The PUBLISH/SUBSCRIBE model connects client that want to exchange information/data/messages. The model consists of the client-server model. Any client communicates with an endpoint via the broker. Before a client wants to publish messages it first has to set up a connection with the broker. Also, a subscribing client has to do the same. Therefore, the broker can decouple the publisher and subscriber. See more


The broker must acknowledge each SUBSCRIBE packet. Therefore the broker sends a SUBACK packet (subscribe acknowledge) to the client.


See more


To discard all stored states and answers a so-called PUBCOMP packet (Publish complete) is sent. That's the end of the QoS2 order of events.


See more


The PUBLISH packet consists of details that indicate to the broker what to do. Read more about these here:


See more


Either one publisher publishes messages to multiple Subscribers. Or multiple publishers publish messages to just one subscriber. Or any combination of multiple publishers/subscribers. Any publisher can only be identified when information about the publisher is included in the topic or payload. See more


A PUBREC Packet is a response to a PUBLISH Packet with QoS 2. It is the second packet of the QoS 2 protocol exchange.


See more


A PUBREL is another packet the broker sends after receiving the PUBREC packet. This packet must be responded to with a PUBCOMP packet.


See more

Quality of Service QoS

The QoS (Quality of Service) defines a certain level of service that enables the publisher to make sure that the certainty and quantity of a subscriber receiving a sent message equal the importance to receive the message at all, plus whether to receive the message only once. Also, a subscriber can set a QoS, defining the importance to receive every message, and whether to accept one message multiple times or not. There are three levels available. See more

QoS 0

The broker/client is delivering the message only once, without confirmation. There is no guarantee that the message sent has been sent to the subscriber. The recipient on the other end does not acknowledge the receipt. Neither is the acknowledgment stored. The QoS0 - level is often referred to be the "fire and forget"-level. See more

QoS 1

Level 1 QoS guarantees the delivery of a message to the receiver at least once. See more

QoS 2

QoS level 2 guarantees each message is received exactly once. See more


When a persistent session is active, the broker must queue the missed messages. Whenever a persistent session is created by the client, and the broker already queued messages of an earlier persistent session, the broker delivers the queued messages using the same old session. See more

Retained Message

A retained message safes the last known value of the topic. It's only possible to save up to one retained message, equal to one retained value. The retainFlag identifies a message to be a retained message. To identify the message itself the packetId is used. See more

Return Code

The return code is used within a SUBACK packet. The broker sends one return code for each topic/QoS-pair that it receives in the SUBSCRIBE packet. The return codes can be:

  • 0 - Success-Maximum QoS0
  • 1 - Success-Maximum QoS1
  • 2 - Success-Maximum QoS2
  • 128 - Failure


If a client connects to the broker a session is started. If a client connects to the broker and another client session already exists with the clientId that the new client has chosen, the old session will be kicked out and taken over.

Session Expiry Interval


Whenever a session ExpiryInterval is set (e.g. 60) a cleanStart is automatically set to “0”. With a sessionExpiryInterval active the sessionState will be saved immediately after the keepAlive runs out (e.g. 120 plus half of the keepAlive - that would be 60 seconds in this case).The sessionState is safed for the amount of time set (in this case 60 seconds). sessionExpiryInterval is solving the problem that you don’t need to send anther CONNECT packet including cleanSession=1 (MQTT v.3.1.1) to discard the session after set it retained.


To receive messages on topics of interest, the client sends a SUBSCRIBE packet to the broker.


See more


Direct contact between subscriber and publisher is never able. Only the broker enables transmitting messages. Also, the subscribing client only has one duty. To subscribe to the topic it wants to receive messages from. The subscriber-only knows about the existence of the publisher as the client subscribes to the published topics. See more


A subscription consists of a packetId. And the subscriptions the subscriber wants to subscribe to. Each subscription consists of a topic and a QoS level. When subscriptions overlap, the broker delivers the message that has the highest QoS level for the specific topic.


See more


TCP is embedding TLS (Transport Layer Security). Allowing MQTT packets to be transmitted via encrypted pipes. TLS protects all parts of an MQTT packet, not only the payload. See more


Using Transport Layer Security (TLS) provides a secured communication channel a client and a server can use to connect. TLS is a cryptographic protocol, that uses a handshake mechanism to create a secure connection between client and server. See more


The topic is set using a simple UTF-8 string. Topics are treated hierarchically. To delimiter, a slash "/" symbolizes a separation. Allowing the client organizational structure, much like a common filesystem. There is no need for creating a topic. You can subscribe to any topic, even though there might not be messages published. On the other hand, you must know about the topic names to be able to subscribe to them. See more


A client can always UNSUBSCRIBE from a topic. The UNSUBSCRIBE packet includes the packetId and list of topics the subscriber wants to unsubscribe from.



MQTT can forward and handle username and password within a sent packet. See more


Subscribing to several topics simultaneously is an option that's possible. There are two kinds of wildcards: single-level and multiple levels. See more

"#" is used, the client subscribes to each topic that's after the #.



“+” is the wildcard used to match a single level of hierarchy.