Nouvelles Accueil » Entreprise » What is MQTT?

What is MQTT?

E-Lins Technology 7 21 avr.

MQTT is a lightweight, publish-subscribe network protocol designed for constrained devices and low-bandwidth, high-latency, or unreliable networks. It is ideal for Internet of Things (IoT) and Machine-to-Machine (M2M) communication.

1) How does the MQTT publish/subscribe model work?

Instead of communicating directly with a device, clients (publishers or subscribers) connect to a central broker. Publishers send messages to specific topics, and subscribers receive messages from topics they are interested in. The broker handles all message routing.

2) What is an MQTT Broker?

The broker is the server that receives all messages from publishers, filters them, determines which subscribed clients are interested, and then forwards the messages to those subscribers. Examples include Mosquitto, HiveMQ, and EMQX.

3) What are MQTT Topics?

Topics are UTF-8 strings that act as addresses for message routing. They are structured hierarchically with forward slashes (/) as separators (e.g., home/livingroom/temperature). Subscribers can use wildcards (+ for a single level, # for multiple levels) to subscribe to multiple topics.

4) What are MQTT QoS Levels and why are they important?

Quality of Service (QoS) defines the guarantee of delivery for a message. There are three levels:

  • QoS 0 (At most once): Fastest, no guarantee ("fire and forget").
  • QoS 1 (At least once): Guarantees delivery, but duplicates may occur (acknowledged delivery).
  • QoS 2 (Exactly once): Highest assurance, guarantees delivery exactly once (most overhead).

5) What is the "Last Will and Testament (LWT)" feature?
LWT is a message configured by a client during connection. If the client disconnects ungracefully (e.g., due to network failure), the broker will automatically publish this predefined message to a specified topic, alerting other clients of the abnormal disconnection.

6) What is MQTT-SN (MQTT for Sensor Networks)?

MQTT-SN is a variation of the protocol designed specifically for wireless sensor networks (WSN) with non-TCP/IP communication links (e.g., ZigBee). It addresses constraints like shorter message lengths and uses a gateway to bridge to a standard MQTT broker.

Please visit E-Lins Technology Co, Ltd. for more details.