This topic describes how to use the message tracing function of Message Queue for MQTTto 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. Log on to the Message Queue for MQTTconsole. In the top navigation bar, select a region from the Region drop-down list, such as 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 the Client ID field, enter an MQTT client ID in the format of <groupid>@@@<deviceid>. Set a time range in the time picker, and then click Search.
    Note The maximum time span is one day.
    Field Description
    Time The time when an action occurs.
    Connection ID The ID of a connection.
    Action
    • connect: The MQTT client requests connection to the MQTT broker.
    • close: The TCP connection is disconnected.
    • disconnect: The MQTT client sends a request for disconnecting from the MQTT broker.
    Description
    • accepted: The MQTT broker receives the connection request from the MQTT client.
    • 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 an MQTT client ID conflict.
    • topic auth failed: The TCP connection is disconnected because verification of the client access permission to the topic fails.
    • no heart: The TCP connection is disconnected due to no heartbeat.
    • closed by client: The TCP connection is disconnected due to an MQTT client exception.
      Note The MQTT client does not send the disconnect message.
    • disconnected by client: The MQTT client requests a disconnection.

Query message traces

  1. Log on to the Message Queue for MQTTconsole. In the top navigation bar, select a region from the Region drop-down list, such as 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 Combined query. In the Client ID field, enter an MQTT client ID in the format of <groupid>@@@<deviceid>. In the Message ID field, enter a message ID. Set a time range in the time picker, and then click Search.
      Note The maximum time span is one day.
    • 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 the Client ID field, enter an MQTT client ID in the format of <groupid>@@@<deviceid>. Set a time range in the time picker, and 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 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.
      Field Description
      Time The time when the message is sent or delivered.
      Client IDs The ID of the MQTT client that sends or delivers the message.
      Description
      • Publish From MQTT Client: The MQTT client sends the message.
      • Push To MQTT Client: The message is delivered to the MQTT client.
      • Publish From MQ Client: The Message Queue for Apache RocketMQ (RocketMQ) client sends the message.
      • Push Offline Msg To MQTT Client: The offline message is delivered to the MQTT client.