Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

retained message

A message the broker keeps and hands to anyone who subscribes later, so they get the last known value at once.

A publish with the retain flag set replaces the broker's stored message for that topic; every new matching subscription immediately receives it with retain=1, and a retained publish with an empty payload deletes it.

Examples

  • The sensor publishes the fan state on retained to gh1/dev-a1/state/fan at 8:20; a dashboard subscribing at 9:00 gets on at once.

  • Clearing a retained value needs a null payload, mosquitto_pub -t gh1/dev-a1/status -r -n, not the text "".

Read the full section →