IoT device messaging
A broker that keeps a connection open to every device in a fleet, knows who each one is, and copes with devices that keep dropping offline.
6 technologies on this page ↓How it works
Each device keeps one long-lived connection to a broker, usually MQTT over TLS on port 8883, or over WebSockets on port 443 where firewalls block anything else. Because the device dials out, the cloud can reach it behind NAT. The device proves who it is with its own X.509 client certificate or a token, and the broker checks a policy that says which topics that identity may use, typically only its own, such as devices/pump-7/#. Telemetry goes up as small messages on topics; commands come down on topics the device subscribes to. Each message has a quality of service: QoS 0 is sent once and may be lost, QoS 1 is resent until acknowledged and may arrive twice, and QoS 2 adds a handshake for exactly once, though AWS IoT Core, Azure IoT Hub and Event Grid stop at QoS 1. Devices on cellular or satellite links drop off all the time, so MQTT has tools for that. A persistent session keeps an offline device’s subscriptions and queues its QoS 1 messages until it returns. A retained message is the last value on a topic, handed to anyone who subscribes later. A last will is a message the device registers when it connects, which the broker publishes if the connection dies without a clean goodbye. Platforms add a device shadow or twin: a JSON document in the cloud with the state the device last reported and the state an app wants, so apps can read and change a device that is asleep. A rules engine subscribes to topics and forwards matching messages, filtered with SQL, into queues, streams, databases and functions. On the device, client libraries can hold outgoing QoS 1 messages in memory while the link is down and send them after reconnecting.
A harbour master’s radio desk for a fishing fleet. Every boat has its own call sign, checks in on the radio, and reports its catch on its own channel. Messages for a boat that’s out of range wait on the desk until it calls in again, a board shows each boat’s last known position to anyone who walks in, and if a boat goes silent without signing off, the desk raises the alarm.
Reach for it when
- Thousands or millions of small devices sending telemetry over cellular, satellite or patchy Wi-Fi
- Sending commands or configuration to devices that are often asleep or out of coverage
- Knowing which devices are online, from last wills and connect and disconnect events
- Each device needs its own identity that can be revoked when it is stolen or retired
Think twice when
- Servers talking to servers in one data centre; a queue, a stream or plain HTTP is simpler
- Large files such as firmware images: brokers cap message size (IoT Hub at 256 KB), so send a link instead
- Replaying history for analytics; a broker isn’t a log, so route device data into a stream
- You need exactly-once delivery from a managed cloud broker; the big three stop at QoS 1, so make handlers idempotent
A real example
A water utility has 4,000 pumps on cellular modems. Each pump has its own certificate and may only publish to devices/<its id>/telemetry and subscribe to devices/<its id>/commands. Pressure readings go out every five seconds at QoS 0, since the next reading is never far behind. A rule sends readings above 80 psi to an alerting function and everything else to a time-series database. When an operator lowers a pump’s speed, the command goes out at QoS 1 to the pump’s persistent session, so a pump that is out of coverage gets it when it reconnects. Each pump’s last will publishes offline to its status topic, so the dashboard learns within one and a half keep-alive periods that a modem has died.
Technologies
Specific products, and what each does differently.
AWS IoT CoreAWSAWS’s managed MQTT broker for devices, with per-device certificates, a SQL rules engine that routes messages into AWS services, and cloud-side device state.
Eclipse ZenohIncubatingOpen sourceA pub/sub, query and storage protocol that runs peer to peer or through routers, from microcontrollers to the cloud; also a ROS 2 middleware.
EMQXCommercialAn Erlang MQTT broker built for very large device fleets, with a SQL rule engine, now under the Business Source License. AWS IoT Core | Managed service on AWS | Amazon Web Services | Proprietary; the AWS IoT Device SDKs are open source (Apache 2.0; the Embedded C SDK is MIT) | 2026-10-06 |
| Managed service on Azure | Microsoft | Proprietary; the Azure IoT device and service SDKs are open source (MIT) | 2026-10-06 | |
Eclipse ZenohIncubating | Open source | Eclipse Foundation; developed mainly by ZettaScale Technology | Dual-licensed: EPL 2.0 or Apache 2.0 | 2026-10-06 |
EMQX | Commercial product | EMQ Technologies Inc. | Business Source License 1.1 since 5.9.0 (May 2025; source-available, not OSI open source, each version becomes Apache 2.0 after four years); Apache 2.0 core up to 5.8.x; EMQX Cloud is proprietary | 2026-10-06 |
| Commercial product | HiveMQ GmbH | Proprietary (HiveMQ Platform and HiveMQ Cloud); the single-node Community Edition, HiveMQ Edge and the MQTT client and CLI are Apache 2.0 | 2026-10-06 | |
| Open source | OASIS (open standard) | Open standard, free to implement: OASIS Non-Assertion IPR mode; 3.1.1 is also ISO/IEC 20922 | 2026-10-06 |
What each provider calls it
- AWS
- AWS IoT Core (MQTT 3.1.1 and 5, QoS 0 and 1, Device Shadow, rules engine)
- Google Cloud
- No managed broker: Cloud IoT Core was retired on 16 August 2023. Google points to partner IoT platforms (such as ClearBlade, EMQ and KORE), a self-run MQTT broker on GKE or Compute Engine, or devices publishing straight to Pub/Sub
- Azure
- IoT Hub (device twins, fixed topics, a subset of MQTT 3.1.1); Event Grid’s MQTT broker (MQTT 3.1.1 and 5, custom topics)
- Open source & others
- Eclipse Mosquitto (EPL/EDL), HiveMQ Community Edition (Apache 2.0), EMQX (Business Source License from 5.9), RabbitMQ’s MQTT plugin; Eclipse Zenoh for peer-to-peer and robotics
In code · python
# A device on any MQTT 5 broker: certificate identity, last will, retained status,
# a persistent session for commands, and QoS 0 telemetry (paho-mqtt 2.x)
import json, time
import paho.mqtt.client as mqtt
from paho.mqtt.properties import Properties
from paho.mqtt.packettypes import PacketTypes
DEVICE = "pump-7"
client = mqtt.Client(mqtt.CallbackAPIVersion.VERSION2, client_id=DEVICE, protocol=mqtt.MQTTv5)
client.tls_set(ca_certs="ca.pem", certfile=f"{DEVICE}.crt", keyfile=f"{DEVICE}.key")
# if the connection dies without a DISCONNECT, the broker publishes this for us
client.will_set(f"devices/{DEVICE}/status", "offline", qos=1, retain=True)
def on_connect(client, userdata, flags, reason_code, properties):
client.publish(f"devices/{DEVICE}/status", "online", qos=1, retain=True)
client.subscribe(f"devices/{DEVICE}/commands", qos=1)
def on_message(client, userdata, msg):
print("command:", msg.payload.decode())
client.on_connect = on_connect
client.on_message = on_message
props = Properties(PacketTypes.CONNECT)
props.SessionExpiryInterval = 24 * 3600 # broker keeps queued commands for a day
client.connect("broker.example.com", 8883, keepalive=60, clean_start=False, properties=props)
client.loop_start()
while True:
reading = {"psi": 61.2, "ts": int(time.time())}
client.publish(f"devices/{DEVICE}/telemetry", json.dumps(reading), qos=0)
time.sleep(5)Often confused with
Where it came from1999–2023
Remote equipment was watched over costly links long before anyone said “IoT”. In 1999 Andy Stanford-Clark of IBM and Arlen Nipper of Arcom designed MQTT to monitor oil pipelines over satellite, where every byte cost money and batteries had to last. IBM used it internally for about ten years, published MQTT 3.1 royalty-free in 2010, and OASIS approved 3.1.1 as a standard in October 2014.
The clouds then built managed brokers around it. AWS IoT launched in beta in October 2015 with an MQTT broker, a rules engine that routed messages with SQL, and Thing Shadows: cloud copies of each device’s reported and desired state, so apps could work with devices that were offline. Azure IoT Hub offered device twins, and Google’s Cloud IoT Core entered public beta in September 2017 and became generally available in February 2018.
Not every attempt lasted. Google retired Cloud IoT Core on 16 August 2023 and pointed customers to partners such as ClearBlade and EMQ. Microsoft, which says IoT Hub isn’t a full-featured MQTT broker, made an MQTT 3.1.1 and 5 broker in Event Grid generally available in November 2023. Open-source brokers such as Mosquitto, EMQX and HiveMQ remain the way to run it yourself.
Why it’s built this way
- One identity per device
- A shared password means one stolen device exposes the fleet. A client certificate per device lets the broker limit each device to its own topics and revoke just that one.
- Keep each device’s state in the cloud
- Apps can’t wait for a sleeping device to answer. A shadow or twin stores the reported and desired state, and the device catches up on the difference when it reconnects.
- Route with rules, not custom consumers
- Writing a service that subscribes to every topic and forwards data is repetitive. AWS’s rules engine let a SQL
SELECTon a topic send matching messages straight to DynamoDB, S3, Lambda or Kinesis. - Build disconnection into the protocol
- Devices on poor links vanish without warning, so MQTT includes keep-alives, persistent sessions, retained messages and last wills rather than leaving each application to invent them.
Timeline
- 1999
MQTT designed to monitor oil pipelines over satellite
- 2010
IBM publishes MQTT 3.1 royalty-free
- 2014
OASIS approves MQTT 3.1.1 as a standard
- 2015
AWS IoT launches with Thing Shadows and a rules engine
- 2018
Google Cloud IoT Core becomes generally available
- 2019
MQTT 5.0 becomes an OASIS Standard
- 2023
Google retires Cloud IoT Core; Event Grid’s MQTT broker reaches GA
- MQTT.org FAQ: who invented MQTT (1999)
- HiveMQ: MQTT Essentials part 1 (oil pipelines over satellite, 3.1 royalty-free in 2010)
- OASIS: MQTT Version 3.1.1 becomes an OASIS Standard (Oct 2014)
- OASIS: MQTT Version 5.0 specification (OASIS Standard, 7 March 2019)
- AWS News Blog: AWS IoT, cloud services for connected devices (Oct 2015; Thing Shadows, rules engine)
- Google Cloud: Cloud IoT Core release notes (beta Sept 2017, GA Feb 2018, retirement notice) · archived copy, original
- Google Cloud: Cloud IoT Core product page (retired 16 August 2023; migration partners) · archived copy, original
- Microsoft Learn: What’s new in Azure Event Grid (MQTT broker preview May 2023, GA Nov 2023)
- Microsoft Learn: Communicate with an IoT hub using MQTT (IoT Hub isn’t a full-featured MQTT broker)
Sources23
- AWS docs: What is AWS IoT? (MQTT, MQTT over WSS, HTTPS, LoRaWAN)
- AWS docs: MQTT in AWS IoT Core (QoS 0 and 1, persistent sessions, retained messages, LWT, differences from the spec)
- AWS docs: AWS IoT Device Shadow service
- AWS docs: Rules for AWS IoT
- AWS News Blog: AWS IoT launch (bidirectional messaging through NAT and firewalls)
- Microsoft Learn: What is Azure IoT Hub? (identity registry, X.509 and SAS, routing)
- Microsoft Learn: Communicate with an IoT hub using MQTT (8883, WebSockets on 443, no QoS 2, retain not stored, 256 KB)
- Microsoft Learn: Understand and use device twins in IoT Hub
- Microsoft Learn: Overview of the MQTT broker feature in Azure Event Grid
- Google Cloud Architecture Center: Connected device architectures on Google Cloud
- Google Cloud Architecture Center: Standalone MQTT broker architecture
- Google Cloud Architecture Center: IoT platform product architecture (device credentials, X.509, rules engines)
- Google Cloud: Cloud IoT Core product page (retired 16 August 2023; migration partners) · archived copy, original
- OASIS: MQTT Version 3.1.1 specification (QoS levels, Will Message, WebSocket transport)
- OASIS: MQTT Version 5.0 specification (session expiry, Clean Start)
- MQTT.org FAQ: ports 1883 and 8883
- aws-crt-python: MQTT 5 client operation queue behaviour while disconnected
- Eclipse Paho MQTT Python client (2.x API)
- Eclipse Mosquitto: an open-source MQTT broker (EPL/EDL)
- HiveMQ Community Edition repository (Apache 2.0)
- EMQX LICENSE (Business Source License 1.1 for 5.9.0 and later)
- RabbitMQ docs: MQTT plugin
- Eclipse Zenoh: What is Zenoh?