Device status FAQ
This topic answers frequently asked questions about device status in IoT Platform.
How do I activate a device that has an Inactive status in IoT Platform?
An Inactive status means the device has never successfully connected to IoT Platform.
A device is automatically activated the first time it connects to IoT Platform. You can activate a device in one of the following ways:
For more information about connecting a device to IoT Platform, see Device connection guide.
Does an offline status mean the device is powered off?
Not necessarily. A device is considered offline if it disconnects intentionally, loses its network connection, is powered off, or is disabled.
How can I receive device status change notifications?
You can use the rules engine to receive device status change notifications.
You can use the server-side subscription or data forwarding features of the rules engine to configure rules that forward device status change notifications. This lets you receive messages when a device goes online or offline.
For more information, see Communication methods of the rules engine.
Are there delays in device status change notifications?
Yes. Notifications for a device going online or intentionally disconnecting have a short delay. Notifications for abnormal disconnections, such as network loss or power failure, have a longer delay because the system needs time to detect the disconnection.
Why are offline notifications delayed?
When a device connects to IoT Platform using the Message Queuing Telemetry Transport (MQTT) protocol, you must set an MQTT connection heartbeat interval between 30 and 1,200 seconds. For more information, see MQTT connection example.
IoT Platform checks the device's keepalive heartbeat every 30 seconds. The wait time for this check is the duration between when the device comes online and the next scheduled check. The maximum timeout period is defined as: Keepalive heartbeat interval × 1.5 + Wait time for the check. If the server does not receive a message from the device within this maximum timeout period, it automatically closes the connection, and the device status changes to offline.
Therefore, when a device disconnects abnormally, it takes time to detect the offline state. This causes a delay in the status change notification.
Why does the status in a notification sometimes differ from the device's actual status?
Because device status change notifications can be delayed, the time you receive a message may not match the time the device's status actually changed. You must use the timestamp in the message to determine the latest status of the device. For more information, see Data format for online and offline messages.
Offline analysis
If a device sends a disconnect request, its status immediately changes to offline.
If a device disconnects abnormally without sending a disconnect request, IoT Platform uses the heartbeat to determine if the device is offline.
The MQTT connection heartbeat interval must be between 30 and 1,200 seconds. If the interval is outside this range, the server rejects the connection. We recommend a value of 300 seconds or more.
The heartbeat timer starts when IoT Platform sends a CONNACK response to a CONNECT message. The timer resets when it receives a PUBLISH, SUBSCRIBE, PING, or PUBACK message.
If the server does not receive a message within 1.5 times the specified heartbeat interval, it automatically closes the connection. The device status then changes to offline.
For more information about keepalive heartbeats, see MQTT keepalive.