This topic describes how to use the tracing feature of ApsaraMQ for MQTT to troubleshoot device status and messaging problems. When the status of a device is abnormal, you can use the device tracing feature to query the connection history of this device. When messages cannot be sent or received as expected, you can use the message tracing feature to query message sending and receiving traces.
Query device traces
- Log on to the ApsaraMQ for MQTT console. In the top navigation bar, select a region from the Region drop-down list, such as China (Hangzhou).
- In the left-side navigation pane, choose Message Tracing.
- On the Trace query page, click the instance that you want to query, and then click the Device Trace tab.
- Click the Client ID field. Select or enter the client ID in the format of <groupid>@@@<deviceid>. Set a time range in the date picker and click Search. Note The maximum time span is one day.
Field Description Time The time when an action occurs. Connection ID The ID of the connection. Action - connect: The Message Queue for MQTT client requests a connection to the Message Queue for MQTT broker.
- close: The TCP connection is closed.
- disconnect: The Message Queue for MQTT client sends a request to disconnect from the Message Queue for MQTT broker.
Description - accepted: The Message Queue for MQTT broker receives the connection request from the Message Queue for MQTT client.
- not authorized: The TCP connection is closed because the permission verification of the client to access the instance fails.
- clientId conflict: The TCP connection is closed due to a conflict in the Message Queue for MQTT client ID.
- topic auth failed: The TCP connection is closed because the permission verification of the client to access topic resources fails.
- no heart: The TCP connection is closed due to no heartbeat.
- closed by client: The TCP connection is closed due to a Message Queue for MQTT client exception. Note The Message Queue for MQTT client does not send a disconnect message.
- disconnected by client: The Message Queue for MQTT client requests a disconnection.
Query message traces
- Log on to the ApsaraMQ for MQTT console. In the top navigation bar, select a region from the Region drop-down list, such as China (Hangzhou).
- In the left-side navigation pane, choose Message Tracing.
- On the Trace query page, click the instance that you want to query, and then click the Message trace tab.
- You can query messages by using one of the following methods:
- Combined query
You can query the sending and delivery traces of a message by specifying the client ID, message ID, and time range.
Click Combined query. In the Client ID field, select or enter a Message Queue for MQTT client ID in the format of <groupid>@@@<deviceid>. In the Message ID field, select or enter a message ID. In the time picker, set a time range. Then, click Search.Note The maximum time span is one day. - Query by Client ID
You can query the message list of a Message Queue for MQTT client by specifying the client ID and time range.
Click Query by Client ID. In the Client ID field, select or enter a Message Queue for MQTT client ID in the format of <groupid>@@@<deviceid>. In the time picker, set a time range. Then, click Search.Note The maximum time span is one day. - Query by Message ID
You can query the sending and delivery traces of messages that have the same message ID by specifying the message ID and time range.
Click Query by Message ID. Select or enter a message ID in the Message ID field, and set a time range in the time picker. Then, click Search.Note The maximum time span is one day.Field Description Time The time when the message is sent or delivered. Client IDs The ID of the Message Queue for MQTT client that sends the message or to which the message is delivered. Description - Publish From MQTT Client: The Message Queue for MQTT client sends the message.
- Push To MQTT Client: The message is delivered to the Message Queue for MQTT client.
- Publish From MQ Client: The ApsaraMQ for RocketMQ client sends the message.
- Push Offline Msg To MQTT Client: The offline message is delivered to the Message Queue for MQTT client.
- Combined query