MQTT (Message Queuing Telemetry Transport) is an application layer protocol typically run over TCP, commonly used as a backend for cloud platforms.
MQTT is a publish-subscribe network protocol that consists of a message broker and one or more clients. Information is organized via topics; clients can publish and subscribe to specific topics through the MQTT broker. When publishing to a topic, all clients subscribed to that topic will receive the message from the MQTT broker.
An MQTT broker is essentially 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 multiple clients can publish to the same topic as well.
MQTT allows for the decoupling of the client-side and server-side, so connected clients are unaware of each other’s information.
The MQTT protocol has a keep-alive function that ensures the connection between the broker and the client stays alive. When connecting to a broker, the client specifies a keep-alive interval, the maximum time the broker and client can go without communicating before the connection is closed. The broker can also set a keep-alive time; if the broker’s keep-alive time is shorter, this can close the connection on the broker-side.
When connecting to the broker, the client can specify a quality of service (QoS) level.
MQTT supports numerous authentication and data security mechanisms. In this course, we will focus on connection to the MQTT broker via 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.