Last will messages
Network connections can be volatile, and there are many things that can lead to them being disconnected—temporarily or permanently. Not only can a connection fail, but a device might run out of power (blackout or empty batteries). MQTT has an option called last will/testament, which makes it possible to publish a message when a device goes offline: a protocol or I/O error occurs when the device does not call back in a certain amount of time (the keep-alive time), or the application gets terminated without being disconnected from the server properly.
Similar to a regular MQTT message, a last will message is sent to a certain channel. A very good use case for the last will feature is posting an update to a status channel. ...
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