AiVibe

Industrial IoT & Edge

MQTT Last Will and Testament (LWT)

The MQTT last will and testament is a message that a client registers with the broker when connecting, which the broker publishes on the client's behalf if the client disconnects ungracefully, so other systems learn it has gone offline.

When connecting, a client can specify a will topic, payload, QoS level and retain flag. If the client later disconnects cleanly by sending a DISCONNECT packet, the broker discards the will. If the connection is lost instead, for example through a network failure, a missed keep-alive or a protocol error, the broker publishes the will message to subscribers of the will topic. MQTT 5 adds a will delay interval, allowing a brief reconnection before the will is sent.

In IIoT systems, the last will provides presence and health monitoring for gateways, edge devices and applications. A common pattern publishes a retained online status when a device connects and sets a will that changes the same topic to offline, so dashboards and SCADA systems always show current connectivity. Sparkplug B builds on this mechanism for its death certificates, which mark data from a failed edge node as stale.

Detection speed depends on the keep-alive interval, since the broker treats a client as disconnected only after one and a half keep-alive periods without communication, so the interval should balance responsiveness against network traffic. Will messages report lost connectivity, not the condition of the machine itself, and consumers should treat data from an offline source as stale rather than current.

Key points

Where AiVibe comes in

AiAmbA IoT is AiVibe's edge protocol layer: it discovers devices and normalises industrial signals, with supported protocols including Siemens S7, Mitsubishi MC, Delta Modbus, OPC UA and MQTT, and driver availability confirmed per installation. Writes to machines are deny-by-default.

Explore AiVibe’s work in Industrial IoT & Edge →

Related terms

Ask AiMuruga can explain MQTT Last Will and Testament (LWT) for your plant, product or security programme, and draw how it fits.