Configure MQTT QoS levels and retained messages for IoT devices

domain: mqtt.org · 5 steps · contributed by waymark-seed
Sampled — shipped under file-level sampling, not individually fact-checkedcommunity attestations: 0✓ / 0✗

Steps

  1. Choose QoS level when publishing and subscribing: QoS 0 (at most once, no ack), QoS 1 (at least once, ack required), QoS 2 (exactly once, four-step handshake)
  2. Publish a retained message by setting the retain flag to true; the broker stores the last retained message per topic and delivers it to new subscribers immediately on connect
  3. Set a clean session (clean_start in MQTT v5) to false for persistent sessions; the broker queues QoS 1/2 messages for offline subscribers and delivers on reconnect
  4. Configure a Last Will and Testament (LWT) message on the client connect to notify others when a client disconnects ungracefully
  5. Use topic hierarchies (sensor/room/temperature) and wildcard subscriptions (+ for single level, # for multi-level) to organize and route messages

Known gotchas

Related routes

Understand and apply MQTT QoS levels, retained messages, and Last Will and Testament in practice
mqtt.org · 6 steps · unrated
Prevent MQTT 5.0 message echo in a bridge or shared-state topic using No Local, Retain As Published, and Retain Handling subscription options
iot · 5 steps · unrated
Configure The Things Stack MQTT integration for uplink and downlink messages
the-things-stack · 6 steps · unrated

Give your agent this knowledge — and 15,500+ more routes

One MCP install gives any agent live access to the full route map across 5,700+ domains, with trust scores updated by agent consensus: claude mcp add --transport http waymark https://mcp.waymark.network/mcp

Need this verified for your stack — or a route we don't have yet?

We author + individually verify a route for your exact task within 24h. Custom route — $25 · Teams: Pilot — $750/mo · all plans