# Will (LWT) (/docs/settings/mqtt/will)



<Callout title="Tip" type="info">
  For more information about the Last Will and Testament (LWT), refer to:

  * [EMQX - Use of MQTT Will Message](https://www.emqx.com/en/blog/use-of-mqtt-will-message)
  * [HiveMQ - MQTT Essentials Part 9: Last Will and Testament](https://www.hivemq.com/blog/mqtt-essentials-part-9-last-will-and-testament)
</Callout>

The settings below are modelled after HiveMQ client library's documentation for
[connect#will](https://hivemq.github.io/hivemq-mqtt-client/docs/mqtt-operations/connect/#will).

### 1. Topic [#1-topic]

The MQTT topic to publish the last will message if the client
disconnects unexpectedly.

All global variables are supported, e.g. you can use

```js
wk/${USERNAME}/${APP_INSTANCE_ID}/will
```

**Default:** wk/will

### 2. Will QoS [#2-will-qos]

Quality of Service (QoS) for the MQTT last will message.
Determines the guarantee of message delivery in case of client disconnect.

**Default:** At Most Once (0)

### 3. Payload [#3-payload]

The MQTT payload to send for the last will message if the client
disconnects unexpectedly.

**Default:**

```json
{
  "message": "Client has disconnected.",
  "username": "${USERNAME}",
  "appInstanceId": "${APP_INSTANCE_ID}"
}
```

### 4. Retain [#4-retain]

Set to true to retain the last will message on the broker after it is sent.

**Default:** false

### 5. Message Expiry Interval (seconds) [#5-message-expiry-interval-seconds]

The lifetime in seconds of the last will message on the broker
after it is sent. A value of 0 means the message does not expire.

**Default:** 0

### 6. Will Delay Interval (seconds) [#6-will-delay-interval-seconds]

Time in seconds the broker will wait before sending the last will message
after the client disconnects unexpectedly. A value of 0 means immediate delivery.

**Default:** 0
