last will
A message a client leaves with the broker in advance, which the broker publishes for it if the client disappears without saying goodbye.
The last will (topic, payload, QoS, retain) is registered at CONNECT; the broker publishes it when the connection ends without a DISCONNECT packet -- a dropped socket or a keepalive timeout -- and discards it on a clean disconnect.
Examples
At connect, the sensor registers a will of
offline, retained, QoS 1, ongh1/dev-a1/status; if its power fails, the broker publishes it.Before a planned shutdown the device publishes
offlineitself, because a clean disconnect does not trigger the will.
See also