Message Queue Telemetry Transport (MQTT)

What is MQTT:

MQTT is a connectivity protocol designed for Machine to Machine (M2M). It is an extremely lightweight publish/subscribe messaging transport that is ideal for connecting small devices connected on networks with minimal bandwidth.  First developed by IBM for an industrial customer in 1999, but was released into the public domain in 2011.  MQTT is typically used for small devices to publish their statuses (or events) to a MQTT broker (program running on a computer); the broker in turn sends the messages onto all subscribers.  Subscribers can then publish control messages to the broker which will forward them to subscribers (and typically the originating device will subscribe to these control messages.  Messages are filtered by being assigned to a topic by the originating publisher, and subscribers identify which topics they wish to subscribe to.  The MQTT allows for the publisher to identify how much data the broker should keep (i.e., they can stay to always keep the last message for subsequent subscribers) and what to do if publisher disappears in a contract called a Last Will and Testament (LWT).

img

The open software implementation of a MQTT broker called Mosquito runs quite happily on a Raspberry Pi 2. This implementation allows for secure encrypted communications with publishers and subscribers.  

 MQTT clients (that can act as both publishers and/or subscribers) are readily available in multiple languages including JavaScript which makes it available in most web browser. 

MQTT has many benefits, namely:

  • small message size

  • broker will store and forward messages depending on publishers Last Will and Testement

  • brokers can exchange messages (bridge) to other brokers

  • publisher knows if broker received message

  • subscriber / publisher can run in a browser

For more information: