All Products
Search
Document Center

IoT Platform:Message expiry

Last Updated:Jun 15, 2023

This topic describes the message expiry feature of MQTT 5.0.

Background information

The message expiry feature is suitable for scenarios in which you want IoT Platform to cache messages, such as QoS 1 messages, retained messages, and will messages. If you configure the Message Expiry Interval parameter for a message and the message expires, the cached message is deleted and is not pushed.

image..png

The preceding figure shows how the message expiry feature works:

  1. The business server pushes a QoS 1 message. The validity period of the message is 5 seconds.

  2. The first push failed. The device does not receive the ACK message.

  3. The message expires after 5 seconds. Then, IoT Platform deletes the expired message.

  4. If the device is reconnected, no message is pushed.

    Note
    • After the session expires, the QoS 1 message is deleted regardless of whether the QoS 1 message is valid.

    • After the session expires, retained messages are not deleted. If you want a message to remain valid after the message expires, you can specify the message as a retained message.

Scenarios

The message expiry feature is suitable for scenarios in which you need to remotely control devices. For example, if you want to remotely open a door, you can use the message expiry feature to prevent the door from failing to open due to expired messages. The message expiry feature helps prevent expired messages from being sent to devices. This ensures the accuracy of remote control.