Glossary · Industrial communication
Last will and testament (MQTT)
Also known as: LWT, Last will, Will message
German: Last Will (MQTT)
In MQTT, the last will and testament is a will message that a client registers with the broker when it connects and that the broker publishes on the client's behalf to a defined topic if the connection ends without a normal disconnect, for example after a network failure or a missed keep-alive.
- Industrial communication
- Standards
In one sentence
An MQTT last will is a message a client leaves with the broker, which publishes it if the client disconnects unexpectedly.
Example
Each edge gateway on a packaging line registers the will message offline on plant1/line3/palletizer/status, retained; when its network link fails, the broker publishes it and the MES marks the palletizer's data as stale.
How it applies
- Design: A common pattern combines the will with a retained status topic: the client publishes online after connecting, the will publishes offline when it disappears. Sparkplug B uses the will for its death certificates.
- Timing: The broker only notices a silent client after the keep-alive interval (1.5 times the value) has passed. MQTT 5.0 adds a will delay interval, so a short reconnect doesn't trigger the will.
- Limits: The will reports a lost connection, not the state of the machine. It says nothing about whether the machine is still running, and it is no substitute for a Safety function or a monitored Heartbeat where reaction times matter.
- Documentation: The documentation team documents the will topic, payload, QoS and retain setting, the keep-alive and will delay intervals, and how consumers should react.