All Products
Search
Document Center

IoT Platform:Will messages

Last Updated:Dec 08, 2023

The will message feature is defined in MQTT 3.1.1. IoT Platform supports the feature when you connect devices to IoT Platform over MQTT 5.0. This topic describes will messages.

Background information

Will messages

A will message is sent when a device is connected to IoT Platform. If the device is disconnected from IoT Platform and fails to reconnect to IoT Platform within a period of time that is specified by the Will Delay Interval parameter, IoT Platform publishes the will message to subscribers on behalf of the device. The default value of the Will Delay Interval parameter is 0.image..png

  • The content of a will message is similar to the content of a common message that is sent by a device. The content includes the topic name, payload, QoS level, Retain tag, user properties, and message expiry interval.

  • A device may be disconnected from a server due to the following causes:

    • Network failures or fluctuations. If the device does not communicate with the server within a specified connection persistence period, the server closes the connection.

    • A power outage occurs on the device. The server identifies that the connection is closed.

    • The connection is closed by the server when the device attempts to perform unauthorized operations. For example, the device attempts to subscribe to a topic on which the device does not have permissions.

  • A will message of a device is deleted in the following scenarios:

    • After the device is disconnected as expected, the will message is deleted.

    • After the device is unexpectedly disconnected and IoT Platform publishes the will message on behalf of the device, the will message is deleted.

    • If you do not configure the Message Expiry Interval parameter for the will message, the will message is deleted after the will message expires.

  • You cannot update a will message.

Note
  • Expired sessions do not affect will messages. Will messages can be published regardless of the status of sessions.

  • Will messages support the message expiry feature. If the content of messages expires in a period of time, such as temperature control-related messages, use the will message feature together with the message expiry feature. For more information, see Message expiry.

  • If network signals are weak or network connections are unstable, we recommend that you configure the WillDelayInterval parameter. This prevents will messages from being frequently pushed because devices are frequently connected and disconnected.

Scenarios

Device exception analysis

If the status of a device that is connected to IoT Platform changes, such as the device goes online or offline, IoT Platform pushes a device status-related message to business servers or the rules engine by using the following topic: /as/mqtt/status/${productKey}/${deviceName}. The message includes only the information about the connection status of the device. If you want to obtain more data for device exception analysis, you can use will messages. Will messages can include information about devices, such as environment information.image..png