MQTT is a publish-subscribe messaging protocol, designed for devices with low resources and small bandwidth available. It’s widely used in “Machine to Machine” and “Internet of Things” communication. Each client is connected to a central server, called broker. The broker manages the dispatch of messages. Messages are published by clients on different hierarchical topics, and received only by clients who subcribed to the particular topic. Examples of topics are “/device/sensor”, “das-sade321/asds da/”.
Topics cannot contain the characters
/ since they have special meanings. The forward slash
/ is used as level separator.
+ is a wildcard used in subscriptions and it means “one level”.
# is a wildcard used in subscriptions and it means “any number of levels”.
The protocol itself does not specify a payload format. One interesting feature is that the broker can notify when a client disconnects using a mechanism called Last Will and Testament. Protocol specifications (v3.1.1) are freely available online.
If you wish to read more I suggest proceeding with “MQTT Essentials” by HiveMQ team.
- Introducing MQTT
- Publish & Subscribe
- Client, Broker and Connection Establishment
- MQTT Publish, Subscribe & Unsubscribe
- MQTT Topics & Best Practices
- Quality of Service 0, 1 & 2
- Persistent Session and Queuing Messages
- Retained Messages
- Last Will and Testament
- Keep Alive and Client Take-Over
- MQTT over WebSockets
There are some brokers that are public. They can be used by anyone for testing and development purposes. Be careful not to publish sensitive data!
Here it is a list of publicly available MQTT brokers. (checked on 2016-02-27)
|broker.mqttdashboard.com||1883||MQTT, not encrypted|
|iot.eclipse.org||1883||MQTT, not encrypted|
|iot.eclipse.org||8883||MQTT, encrypted TLS v1.2, v1.1 or v1.0 with x509 certificates|
|mq.thingmq.com||80||MQTT / Websockets, not encrypted|
|mq.thingmq.com||1883||MQTT, not encrypted|
|mq.thingmq.com||8883||MQTT, encrypted SSL|
|mqtt.kgbvax.net||1883||MQTT, not encrypted, max message size 64 KiB|
|mqtt.kgbvax.net||8083||MQTT / Websockets, not encrypted, max message size 64kiB|
|test.mosquitto.org||1883||MQTT, not encrypted|
|test.mosquitto.org||8883||MQTT, encrypted TLS v1.2, v1.1 or v1.0 with x509 certificates|
|test.mosca.io||80||MQTT / Websockets, not encrypted|
|test.mosca.io||1883||MQTT, not encrypted|
|test.mosquitto.org||8080||MQTT / Websockets, not encrypted|
|test.mosquitto.org||8081||MQTT / Websockets, encrypted TLS v1.2, v1.1 or v1.0 with x509 certificates|