This topic describes how to use Message Queue for MQTTcan use the message tracing function of to troubleshoot device status problems and message sending and receiving problems. When the status of a device is abnormal, you can use the device trace function to query the connection history of this device. When messages cannot be sent or received as expected, you can use the message trace function to query message sending and receiving traces.

Query device traces

  1. Login Message Queue for MQTTconsole in the top navigation bar, select a Region. For example, china (Hangzhou).
  2. In the left-side navigation pane, choose Message Tracing.
  3. On the Trace query page, click the target instance, and then click the Device Trace tab.
  4. In Client ID text box, enter your Client ID (the splicing format of Client IDs is <grou@< deviceid>), set the time range in the date selector, and click search.
    Note The maximum time span is one day.
    client_track
    Field Description
    Date The date and time when the action occurred.
    Connection ID The connection id.
    Actions
    • Connect: the client requests the connection with the server.
    • Close: the TCP connection is disconnected.
    • Disconnect: The MQTT client sends a request to disconnect the MQTT broker.
    Description
    • Accepted: The server receives connection requests from clients.
    • Not authorized: the TCP connection is disconnected because verification of the client access permission to the instance fails.
    • clientId conflict: the TCP connection is disconnected due to a client identity conflict.
    • topic auth failed: the TCP connection is disconnected because verification of the client access permission to the topics fails.
    • no heart: the TCP connection is disconnected due to no heartbeat.
    • closed by client: the TCP connection is disconnected due to a client exception.
      Note The MQTT client does not send a disconnect packet.
    • disconnected by client: the client requests a disconnection.

Query a message trace

  1. Login Message Queue for MQTTconsole in the top navigation bar, select a region, for example, china (Hangzhou).
  2. In the left-side navigation pane, choose Message Tracing.
  3. On the Trace query page, click the target instance, and then click the Message trace tab.
  4. You can query messages in the following three ways:
    • Query by multiple criteria

      You can query the sending and delivery traces of a message by specifying the client ID, message ID, and time range.

      Click query by multiple criteria, in Client ID text box, enter your Client ID (the Client ID splicing format is <grou@@< deviceid>), in Message ID enter the Message ID in the text box, set the time range in the time picker, and then click search.
      Note The maximum time span is one day.
      msgtrack
    • Query by client ID

      You can query the message list of an MQTT client by specifying the client ID and time range.

      Click query by Client ID, in Client ID enter a Client ID text box and set a time range in the time picker. Search.
      Note The maximum time span is one day.
      result
    • Query by message ID

      You can query the sending and delivery traces of messages with the same message ID by specifying the message ID and time range.

      Click Query by Message ID. 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.
      msgid_result
      Field Description
      Date The time when the message is sent or delivered.
      Client IDs The ID of the MQTT client that sends or delivers the message.
      Description
      • MQTT client sending: The MQTT client sends a message.
      • Push messages to MQTT clients: The message is delivered to the MQTT client.
      • MQ client sending: Message Queue for Apache RocketMQthe client sends a message.
      • Push offline messages to an MQTT client: an offline message is delivered to an MQTT client.