MQTT (Message Queuing Telemetry Transport) Protocol
MQTT is a lightweight, publish-subscribe network protocol that transports messages between devices. It is designed for connections with remote locations where a "small code footprint" is required or the network bandwidth is limited.
Protocol Overview
- Architecture: Based on a Client/Broker model.
- Transport: Typically runs over TCP/IP, but variants like MQTT-SN (for Sensor Networks) can run over UDP/Bluetooth.
- Port: Default is
1883, while encrypted (TLS/SSL) is8883. - Payload: Can carry up to 256MB of data; control headers can be as small as 2 bytes.
- QoS (Quality of Service):
- Level 0: At most once (Fire and forget).
- Level 1: At least once (Acknowledged).
- Level 2: Exactly once (Four-step handshake).
Features & Security
- Topic System: Uses a hierarchical structure (e.g.,
home/living-room/temperature). - Retained Messages: The broker stores the last message on a topic for new subscribers.
- Last Will and Testament (LWT): Notifies other clients when a client unexpectedly disconnects.
- Security: Basic authentication uses plain-text usernames and passwords. TLS/SSL is highly recommended to protect against interception and tempering.
Recommended Implementations
Brokers
- Eclipse Mosquitto: a popular lightweight open-source MQTT broker.
- Mosquitto Official Site链接mosquitto.orgmosquitto - MQTT broker · eclipse/mosquitto · Topic · sensors/COMPUTERNAME/temperature/HARDDRIVENAME · 级联关系 · - · 匹配 sensors/a/temperature/b笔记:mosquitto
- Eclipse IoT Projects
- EMQX: Scalable, distributed MQTT broker for IoT.
Client Libraries
- Eclipse Paho: A collection of high-quality MQTT client libraries.
-
- eclipse/paho.mqtt.golangGitHubeclipse/paho.mqtt.golang
- Go, EPL-2.0 / EDL-1.0
- The standard MQTT client library for Go. Supports MQTT 3.1, 3.1.1, and V5. Supports TCP, TLS, and WebSockets.
- eclipse/paho.mqtt.golangGitHubeclipse/paho.mqtt.golang
Resources
关联信息
反向链接、本文链接的其他页面和外部资料。
参考资料
GitHub1 条
- eclipse/paho.mqtt.golanggithub.com/eclipse/paho.mqtt.golang
Wikipedia1 条
- Comparison of MQTT implementationsWikipedia:Comparison of MQTT implementations
其他外链5 条
- iot.eclipse.org/projectsiot.eclipse.org/projects
- mosquitto.orgmosquitto.org/
- mqtt.orgmqtt.org/
- mqtt.org/mqtt-specificationmqtt.org/mqtt-specification
- www.eclipse.org/pahowww.eclipse.org/paho