Expiry intervals
Session Expiry
With MQTT3, the Clean Session flag passed during connection establishment can be used to specify whether the message broker saves client session information after disconnection. MQTT5 replaces this setting with a Clean Start flag and the introduction of a Session Expiry interval. The Clean Start flag has the same function as Clean Session in MQTT3. However, if the client's session is not to be deleted directly, the expiry time can be set via Session Expiry (reference: ST_IotMqtt5Connect).
Message Expiry
If a message with QoS 1 or 2 is published and additionally subscribed by a client with QoS 1 or 2 and the client was connected without the Clean Start flag, MQTT3 will hold a message in the message broker until the client is connected again. With MQTT5 it is possible to define an expiration time for a message. After this expiration time, the message will no longer be delivered to clients that were not connected at the time of sending.