All Products
Search
Document Center

ApsaraMQ for MQTT:QueryMqttTraceDevice

Last Updated:Dec 26, 2024

Queries the trace of a device that corresponds to an ApsaraMQ for MQTT client by page. When the status of a device is abnormal, you can call this operation to query the connection history of the device. This helps you efficiently troubleshoot issues.

Operation description

  • Each successful call to the QueryMqttTraceDevice operation increases the messaging transactions per second (TPS) by one. This affects the billing of your instance. For more information, see Billing rules.
  • You can call this operation up to 500 times per second per account. If the limit is exceeded, throttling is triggered. This may affect your business. We recommend that you take note of this limit when you call this operation. For more information, see Limits on QPS.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

There is currently no authorization information disclosed in the API.

Request parameters

ParameterTypeRequiredDescriptionExample
MqttRegionIdstringYes

The ID of the region where the ApsaraMQ for MQTT instance resides. For more information, see Endpoints .

cn-hangzhou
InstanceIdstringYes

The ID of the ApsaraMQ for MQTT instance. The ID must be consistent with the ID of the instance that the ApsaraMQ for MQTT client uses. You can view the instance ID in the Basic Information section on the Instance Details page that corresponds to the instance in the ApsaraMQ for MQTT console.

mqtt-cn-i7m26mf****
ReversebooleanYes

Specifies whether the returned results are displayed in reverse chronological order. Valid values:

  • true: The returned results are displayed in reverse time order of actions on the device. This means that the information about the latest action on the device is displayed as the first entry and the information about the earliest action on the device is displayed as the last entry.
  • false: The returned results are displayed in time order of actions on the device. This means that the information about the earliest action on the device is displayed as the first entry and the information about the latest action on the device is displayed as the last entry.

If you do not specify this parameter, the returned results are displayed in time order of actions on the device by default.

false
ClientIdstringYes

The client ID of the device whose trace you want to query.

GID_test@@@producer
BeginTimelongYes

The beginning of the time range to query. The value of this parameter is a UNIX timestamp in milliseconds.

1621580400000
EndTimelongYes

The end of the time range to query. The value of this parameter is a UNIX timestamp in milliseconds.

1621584000000
CurrentPageintegerYes

The number of the page to return. Pages start from page 1. If the input parameter value is greater than the total number of pages, the returned result is empty.

1
PageSizeintegerYes

The number of entries to return on each page. Valid values: 1 to 100.

5

Response parameters

ParameterTypeDescriptionExample
object
CurrentPageinteger

The page number of the returned page.

1
RequestIdstring

The request ID. You can use the ID to troubleshoot issues. This parameter is a common parameter.

317076B7-F946-46BC-A98F-4CF9777C****
PageSizeinteger

The number of entries returned per page.

2
Totallong

The total number of returned actions on the device.

3
DeviceInfoListarray<object>

The details of the action on the device.

DeviceInfoListobject
ChannelIdstring

The connection ID.

c69fe839209547fa9d073781b9cd****
Timestring

The time when the action occurred on the device.

2021-05-21 15:51:54.867
ActionCodestring

The returned code for the action on the device. Valid values:

  • mqtt.trace.action.connect: This value is returned if the value of Action is connect.
  • mqtt.trace.action.close: This value is returned if the value of Action is close.
  • mqtt.trace.action.disconnect: This value is returned if the value of Action is disconnect.
mqtt.trace.action.connect
Actionstring

The action on the device. Valid values:

  • connect: The ApsaraMQ for MQTT client requests a connection to the ApsaraMQ for MQTT broker.
  • close: The TCP connection is closed.
  • disconnect: The ApsaraMQ for MQTT client requests a disconnection from the ApsaraMQ for MQTT broker.
connect
ActionInfostring

The returned information for the action on the device. Valid values:

  • accepted: The ApsaraMQ for MQTT broker accepts the connection request from the ApsaraMQ 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 ID of the ApsaraMQ for MQTT client.
  • resource auth failed: The TCP connection is closed because the permission verification for the ApsaraMQ for MQTT client to access the topic or group fails.
  • no heart: The TCP connection is closed because no heartbeat is detected on the client.
  • closed by client: The TCP connection is closed because an exception occurs on the client.
  • disconnected by client: The client requests a disconnection.
  • invalid param: The TCP connection is closed due to invalid request parameters.
  • Socket IOException: The TCP connection is closed due to network jitter or packet loss.
accept

Examples

Sample success responses

JSONformat

{
  "CurrentPage": 1,
  "RequestId": "317076B7-F946-46BC-A98F-4CF9777C****",
  "PageSize": 2,
  "Total": 3,
  "DeviceInfoList": [
    {
      "ChannelId": "c69fe839209547fa9d073781b9cd****",
      "Time": "2021-05-21 15:51:54.867",
      "ActionCode": "mqtt.trace.action.connect",
      "Action": "connect",
      "ActionInfo": "accept"
    }
  ]
}

Error codes

HTTP status codeError codeError message
404ApiNotSupportThe specified API is not supported.
500SystemOverFlowAn error occurred while processing your request. Please try again.

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history