All Products
Search
Document Center

ApsaraMQ for MQTT:Query the status of a device

Last Updated:Jul 09, 2026

If an exception occurs on an ApsaraMQ for MQTT device or messages cannot be sent or received as expected, use the device status query to check whether the device is online, review its subscriptions, and trace its connection and messaging history. This helps you quickly identify the cause of the issue.

Prerequisites

Before you begin, make sure that you have:

  • An ApsaraMQ for MQTT instance

  • The Group ID and Device ID of the device to inspect

Query the device status

  1. Log on to the ApsaraMQ for MQTT console. In the left-side navigation pane, click Instances.

  2. In the top navigation bar, select the region where your instance resides. On the Instances page, click the instance name to go to the Instance Details page.

  3. On the Instances page, find your instance and choose More > Device Status Query in the Actions column.

  4. On the Device Status Query page, enter the Group ID and Device ID, then click Search.

The query results are organized into three tabs: Device status, Device Trace, and Message Trace.

Understand the query results

Device status tab

The Device status tab shows the current connection state and session configuration of the device.

FieldDescription
Client IDThe unique identifier of the MQTT client.
StatusThe connection state: Online or Offline.
Client AddressThe IP address of the client.
cleanSessionWhether the broker clears previous subscriptions and queued offline messages when the client reconnects. When set to true, the broker starts a clean session each time. When set to false, the broker restores the previous session state, including subscriptions and undelivered messages. For details, see the cleanSession section of the Terms topic.
Last Updated AtThe timestamp of the most recent status change.

Subscription section

The Subscription section, displayed below the device status fields, lists all topics the device currently subscribes to.

FieldDescription
Parent TopicThe level-1 topic in ApsaraMQ for MQTT that the client subscribes to.
SubtopicThe level-2 or level-3 topic under the parent topic.
QoSThe quality of service (QoS) level for message delivery between the client and the broker. QoS determines the delivery guarantee: 0 (at most once), 1 (at least once), or 2 (exactly once). For details, see Combinations of QoS levels and the cleanSession parameter.

Troubleshoot Client ID conflicts

If a device unexpectedly goes offline or disconnects repeatedly, a Client ID conflict may be the cause. A conflict occurs when the same Client ID initiates multiple concurrent connections (duplicate connections). ApsaraMQ for MQTT retains only the most recent connection and forcibly disconnects (kicks off) earlier ones.

How to troubleshoot

  1. In the query results, click the Device Trace tab to view the connection history of the device.

  2. If multiple connection records appear from different access points or IP addresses with overlapping timestamps within a short time window, this confirms a Client ID conflict.

  3. Review the source information in each connection record — including the IP address and access endpoint — to identify which client initiated the duplicate connection.

Resolution

Ensure that each physical device uses a globally unique Client ID. Do not share or reuse the same Client ID across multiple devices or allow concurrent connections with the same Client ID, as this causes mutual disconnections.

Device Trace tab

The Device Trace tab shows the connection history of the device, including connect and disconnect events with timestamps. Use this tab to identify intermittent connectivity issues or unexpected disconnections.

For field descriptions, see Query the connection history of a device.

Message Trace tab

The Message Trace tab shows the message list for the device, including published and received messages. Use this tab to verify whether messages were delivered or to identify missing messages.

For field descriptions, see Query message traces.

FAQ

How do I confirm whether an MQTT subscription relationship has expired or is currently active?

The ApsaraMQ for MQTT console does not provide a direct entry to query historical subscription expiry events. To confirm the current subscription status of a device:

  1. Log on to the ApsaraMQ for MQTT console and navigate to the Device Status Query page for your instance.

  2. Enter the Group ID and Device ID of the device, then click Search.

  3. In the query results, check the Subscription section to see whether the device currently subscribes to the expected topics.

To troubleshoot historical subscription failures, check device-side logs to confirm whether a SUBSCRIBE packet was sent after the device reconnected. Note: even when cleanSession is set to false, the device must actively resubscribe after reconnection to receive new messages. Combine the connection history from the Device Trace tab with device logs to infer when a subscription became inactive.

How do I view the exact offline time of a device, or determine whether the offline status shown in monitoring is accurate?

To view the precise time when a device went offline:

  1. Go to the Device Status Query page, enter the Group ID and Device ID, then click Search.

  2. In the query results, click the Device Trace tab.

  3. The Device Trace tab lists all connect and disconnect events with precise timestamps. Use these records as the authoritative source for the exact disconnection time.

Note the following when interpreting results:

  • If the Device Trace tab shows no data, or shows the device as online while monitoring shows it as offline, the discrepancy may be caused by monitoring data collection delays. Refresh the page to retrieve the latest connection status.

  • The Last Updated At field in the Device status tab shows the time of the most recent client status change, which may not reflect the exact moment of disconnection. For the precise disconnection time, refer to the Device Trace records.

How do I view the concurrent online connections and their details for an MQTT instance?

You can check the concurrent online connections count and connection details at different levels of granularity:

  1. Instance-level overview (concurrent online connections count): In the ApsaraMQ for MQTT console, go to the instance details page. The overview panel displays the current client connection count, which shows the total number of concurrent online connections for the instance.

  2. Per-device details (specific values for individual connections): To view the online status and connection details for individual devices, use the Device Status Query feature described in this topic. Enter the Group ID and Device ID to query specific device connection information.

  3. Historical trends and billing statistics: To view historical connection count trends or billing-related connection statistics, refer to the relevant billing documentation or the monitoring charts available in the console.

See also