MQTT v5 Last Will and Testament

last-will-messages-iconThe Last Will message in MQTT v5  functions the same way as that of last will v3.1.1 ,however the last Will messages has been expanded considerably from version 3.1.1.

In version 3.1.1 the last Will message contained:

  1. Topic and QOS
  2. payload
  3. Retain Flag

In MQTT v5 we have:

  1. Topic and QOS
  2. Payload
  3. Retain Flag
  4. Will delay Interval
  5. Payload Format Indicator -i.e binary or UTF-8
  6. Message Expiry Interval
  7. Content Type
  8. Response Topic
  9. Correlation Data
  10. User Property

Will Delay Interval

This is a 4 byte field with the interval in seconds and is 0 by default which means there is no delay in sending the last Will Message.

The field is meant to be used to  cater for very temporary network failures.

Additional Properties 5-10

These are present because the message payload in MQTT v3.1.1 has been expanded in MQTT v5.

They serve the same purpose as those fields in a standard message payload and you can find more details of these fields in these tutorials:


Although the last will message in v5 contains more properties than v3.1.1 it functions the same way and the purpose is to provide state information for a connected client.

MQTT implementations like sparkplug also provide state information by using birth message.

You can find an example implementation in the tutorial Checking Active MQTT Client Connections

Related Tutorials and Resources

Please rate? And use Comments to let me know more

Leave a Reply

Your email address will not be published. Required fields are marked *