If you are having issues with the exercises, please create a ticket on DevZone:
Click or drag files to this area to upload. You can upload up to 2 files.

MQTT protocol

MQTT (Message Queuing Telemetry Transport) is an application layer protocol that runs over TCP, commonly used as a backend for cloud platforms.

MQTT is a publish-subscribe network protocol that consists of a message broker and a number of clients. Information is organized via topics and clients can both publish and subscribe to specific topics using the MQTT broker. When publishing to a topic, all clients subscribing to that topic will receive the message from the MQTT broker.

MQTT broker

An MQTT broker is just a server that receives messages from connected clients and routes them to the applicable destination clients. Multiple clients can be subscribed to a single topic and a single client can be subscribed to topics with the broker.

MQTT allows for the decoupling of the client-side and server-side, so connected clients are unaware of each other’s information.

MQTT network structure

The MQTT protocol has a keep-alive function that ensures the connection between the broker and the client. When connecting to a broker, the client specifies a keep-alive interval which is the maximum time that the broker and client can go without communicating before the connection is closed. The broker can also set a maximum keep-alive time (typically 60 seconds). If the client’s keep-alive interval is longer, this can close the connection on the broker-side.

Quality of service

When connecting to the broker, the client can specify a quality of service (QoS).

  • At most once – Lowest Quality of Service. The message is sent only once.
  • At least once – Medium Quality of Service. The message is re-tried by the sender multiple times until acknowledgment is received.
  • Exactly once – Highest Quality of Service. The sender and receiver engage in a two-level handshake to ensure message is received only once.


MQTT sends connection credentials in plain text format, and does not include any measures for security or authentication. But it does allow for encryption over TLS. Adding TLS will encrypt the communication between the MQTT client and broker. We will take a look at how to implement TLS in an MQTT connection in Exercise 2.

Register an account
Already have an account? Log in
(All fields are required unless specified optional)

  • 8 or more characters
  • Upper and lower case letters
  • At least one number or special character

Forgot your password?
Enter the email associated with your account, and we will send you a link to reset your password.