MQTT
MQTT is a lightweight publish/subscribe messaging protocol designed for IoT and M2M communication.
Overview
Connecting to a Broker
- Select MQTT from the protocol dropdown
- Configure the connection:
- Broker:
localhostormqtt.example.com - Port:
1883(default) or8883(TLS) - Client ID: Auto-generated or custom
- Broker:
- Click Connect
Connection Settings
| Field | Description | Default |
|---|---|---|
| Broker | Hostname or IP | - |
| Port | Broker port | 1883 |
| Client ID | Unique identifier | Auto-generated |
| Username | Auth username | (optional) |
| Password | Auth password | (optional) |
| Use TLS | Enable encryption | false |
Subscribing to Topics
Once connected:
- Enter a topic pattern in the Topic field
- Click Subscribe
Topic Patterns
| Pattern | Matches |
|---|---|
sensors/temperature | Exact topic |
sensors/+ | Single-level wildcard |
sensors/# | Multi-level wildcard |
Examples:
home/+/temperaturematcheshome/living/temperature,home/bedroom/temperaturehome/#matches all topics underhome/
Publishing Messages
- Enter the target Topic
- Type your message
- Select QoS level
- Toggle Retain if needed
- Click Publish
QoS Levels
| Level | Name | Guarantee |
|---|---|---|
| 0 | At most once | Fire and forget |
| 1 | At least once | Acknowledged delivery |
| 2 | Exactly once | Four-part handshake |
Retained Messages
When Retain is enabled, the broker stores the last message for the topic. New subscribers immediately receive this message.
Message Log
The message log shows:
| Column | Description |
|---|---|
| Direction | ↑ Published / ↓ Received |
| Topic | Message topic |
| QoS | Quality of Service level |
| Payload | Message content |
| Timestamp | When sent/received |
Playground Example
The playground includes an MQTT broker:
Broker: localhost
Port: 19511
Publish Temperature
Topic: sensors/temperature
Message: {"value": 22.5, "unit": "celsius"}
QoS: 1
Retain: false
Subscribe to Sensors
Topic: sensors/#
This will receive all messages published to any sensors/ subtopic.
Example: IoT Sensor
Publisher (Sensor)
Topic: home/living-room/temperature
QoS: 1
Message:
{
"device": "sensor-001",
"temperature": 23.5,
"humidity": 45,
"timestamp": "2024-01-15T10:30:00Z"
}
Subscriber (Dashboard)
Topic: home/+/temperature
Receives temperature from all rooms.
Authentication
For secured brokers:
- Enter Username and Password
- Enable Use TLS for encrypted connections
- Connect
Troubleshooting
Connection Failed
- Verify broker hostname and port
- Check if the broker is running
- Ensure firewall allows the connection
No Messages Received
- Verify topic subscription matches published topic
- Check if wildcard patterns are correct
- Ensure QoS levels are compatible
Authentication Error
- Verify username and password
- Check if the user has subscribe/publish permissions