Summary

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 + # and / since they have special meanings. The forward slash / is used as level separator. The + is a wildcard used in subscriptions and it means “one level”. The # 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.

MQTT Essentials

If you wish to read more I suggest proceeding with “MQTT Essentials” by HiveMQ team.

  1. Introducing MQTT
  2. Publish & Subscribe
  3. Client, Broker and Connection Establishment
  4. MQTT Publish, Subscribe & Unsubscribe
  5. MQTT Topics & Best Practices
  6. Quality of Service 0, 1 & 2
  7. Persistent Session and Queuing Messages
  8. Retained Messages
  9. Last Will and Testament
  10. Keep Alive and Client Take-Over
  11. MQTT over WebSockets
  12. Wrap-Up

Public brokers

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)

Address Port Description
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