What is MQTT?
MQTT (Message Queuing Telemetry Transport) is a lightweight, publish-subscribe messaging protocol designed for constrained devices and low-bandwidth, high-latency, or unreliable networks. It’s ideal for Internet of Things (IoT), M2M (machine-to-machine), and mobile applications.Key Characteristics
Lightweight
Minimal protocol overhead with small packet sizes, perfect for constrained devices and networks.
Publish-Subscribe
Decoupled communication model where publishers and subscribers don’t need to know about each other.
Quality of Service
Three QoS levels (0, 1, 2) to guarantee message delivery based on your needs.
Persistent Sessions
Maintain connection state and queued messages even when clients disconnect.
Publish-Subscribe Model
MQTT uses a broker-based architecture where clients connect to a central broker (HiveMQ CE) that routes messages between publishers and subscribers.Topics
Messages are published to named topics using a hierarchical structure with forward slashes as delimiters:Wildcards
Subscribers can use wildcards to subscribe to multiple topics:-
Single-level wildcard (
+): Matches one level -
Multi-level wildcard (
#): Matches multiple levels
HiveMQ CE MQTT Support
HiveMQ Community Edition provides complete implementation of MQTT protocols:- MQTT 3.1.1
- MQTT 5
Full support for MQTT 3.1.1, the most widely adopted version:
- All QoS levels (0, 1, 2)
- Retained messages
- Last Will and Testament (LWT)
- Clean/persistent sessions
- Username/password authentication
- TLS/SSL encryption
Protocol Versions
| Version | Year | Status | Key Features |
|---|---|---|---|
| MQTT 3.1 | 2010 | Supported | Original standardized version |
| MQTT 3.1.1 | 2014 | Widely Used | Refinements and clarifications |
| MQTT 5.0 | 2019 | Latest | Enhanced features, better error handling |
HiveMQ CE automatically detects the MQTT version from the client’s CONNECT packet and responds accordingly.
When to Use MQTT
MQTT is ideal for:- IoT Devices: Sensors, actuators, smart home devices with limited resources
- Mobile Applications: Push notifications, location tracking, chat applications
- Industrial IoT: Factory automation, machine telemetry, SCADA systems
- Smart Cities: Traffic monitoring, environmental sensors, public transportation
- Healthcare: Patient monitoring, medical device connectivity
- Automotive: Telematics, vehicle-to-vehicle (V2V) communication
MQTT vs Other Protocols
| Feature | MQTT | HTTP/REST | WebSocket |
|---|---|---|---|
| Pattern | Pub/Sub | Request/Response | Bidirectional |
| Overhead | Very Low | Medium | Low |
| Real-time | Excellent | Poor | Excellent |
| QoS | Built-in | Manual | Manual |
| Bandwidth | Minimal | Higher | Low |
| Best For | IoT, M2M | Web APIs | Web Real-time |
Basic MQTT Workflow
Connect
Client establishes a connection to the MQTT broker (HiveMQ CE) using TCP, TLS, WebSocket, or Secure WebSocket.
Next Steps
MQTT 3.1.1
Learn about MQTT 3.1 and 3.1.1 features
MQTT 5
Explore MQTT 5.0 enhancements
Transport Protocols
Configure TCP, TLS, and WebSocket transports
Connecting Clients
Connect MQTT clients to HiveMQ CE
Pub/Sub Guide
Learn publishing and subscribing patterns
Quality of Service
Understand QoS levels
Additional Resources
- MQTT Essentials - Comprehensive guide to MQTT
- MQTT 5 Essentials - MQTT 5.0 feature guide
- MQTT Specification - Official OASIS specifications