Retained messages
If a client subscribes to a topic, let's say, /kitchen/ceiling-light/status (which is either on or off), using QoS 1 or QoS 2, it will get an update whenever the status changes from on to off, or the other way around, even after a reconnect. But this only works when there is an active subscription and QoS 1 or 2 are being used. Imagine that you integrate a new smart device into your setup—a Raspberry Pi-powered status monitor with a display to visualize all of your IoT devices together, so that you know which among them are online or offline. Because this new device does not have any subscriptions, there is no way for it to find out whether the ceiling light is currently on or off. Here, retained messages come into play. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access