This topic describes how to use the trace query feature of ApsaraMQ for MQTT to troubleshoot device connectivity and message delivery issues. If a device has an abnormal status, use the device trace query to view its connection history. If messages are not sent or received as expected, use the message trace query to view the message trace.
Query a device trace
Log on to the ApsaraMQ for MQTT console. In the top menu bar, select a region, such as China (Hangzhou).
In the navigation pane on the left, click Trace Query.
On the Trace Query page, click the target instance, and then click the Device Trace tab.
In the Client ID text box, select or enter a client ID. The client ID must be in the <groupid>@@@<deviceid> format. Set a time range and click Search.
NoteThe maximum time range is 1 day.
Field
Description
Time
The date and time when the action occurred.
Connection ID
The connection identity.
Action
connect: The client requests a connection to the server-side.
close: The TCP connection is closed.
disconnect: The client requests to disconnect from the server-side.
Description
accepted: The server-side accepts the connection request from the client.
not authorized: The TCP connection is closed because access to the instance is denied.
clientId conflict: The TCP connection is closed because of a client ID conflict.
topic auth failed: The TCP connection is closed because access to the topic resource is denied.
no heart: The TCP connection is closed due to a heartbeat timeout.
closed by client: The TCP connection is closed due to a client-side exception.
NoteThe client did not send a disconnect message.
disconnected by client: The client requests to disconnect.
Query a message trace
Log on to the ApsaraMQ for MQTT console. In the top menu bar, select a region, such as China (Hangzhou).
In the navigation pane on the left, click Trace Query.
On the Trace Query page, click the target instance, and then click the Message Trace tab.
You can query a message trace in one of the following three ways:
Combined Query
Queries the sending and delivery trace of a message based on the client ID, message ID, and a time range.
Click Combined Query. In the Client ID text box, select or enter a client ID. The client ID must be in the <groupid>@@@<deviceid> format. In the Message ID text box, select or enter the message ID. Set a time range and click Search.
NoteThe maximum time range is 1 day.
Query by Client ID
Queries the message list for a client based on the client ID and a time range.
Click Query by Client ID. In the Client ID text box, select or enter a client ID. The client ID must be in the <groupid>@@@<deviceid> format. Set a time range and click Search.
NoteThe maximum time range is 1 day.
Query by Message ID
Queries the sending and delivery trace of messages based on a message ID and a time range.
Click Query by Message ID. In the Message ID text box, select or enter the message ID. Set a time range and click Search.
NoteThe maximum time range is 1 day.
Field
Description
Time
The date and time when the message was sent or delivered.
Client IDs
The IDs of the clients that sent or received the message.
Description
MQTT Client Send: An MQTT client sends a message.
Push to MQTT client: The message is delivered to an ApsaraMQ for MQTT client.
MQ client sends: An ApsaraMQ for RocketMQ client sends a message.
Push offline message to MQTT client: An offline message is delivered to an ApsaraMQ for MQTT client.