Queries the traces of a device corresponding to a ApsaraMQ for MQTT client by page. When a device is in an abnormal state, you can call this operation to query the connection history of the device. This helps you locate the problem and identify the cause of the problem.
Billing
Each successful call to the QueryMqttTraceDevice operation increases the messaging transaction per second (TPS) by one. Therefore, you are charged for the call. For more information about the billing details, see Billing.
QPS limit
The queries-per-second (QPS) limit on this operation is 500 per user. Throttling is triggered if the number of calls to this operation exceeds this limit. Throttling may affect your business. Therefore, call this operation based on your needs. For more information, see QPS limits.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | QueryMqttTraceDevice | The operation that you want to perform. Set the value to QueryMqttTraceDevice. |
MqttRegionId | String | Yes | cn-hangzhou | The region ID of the ApsaraMQ for MQTT instance. For more information, see Endpoints. |
InstanceId | String | Yes | mqtt-cn-i7m26mf**** | The ID of the ApsaraMQ for MQTT instance. The value must be the instance ID used on the ApsaraMQ for MQTT client. You can view the instance ID in the Basic Information section on the Instance Details page of the instance in the ApsaraMQ for MQTT console. |
ClientId | String | Yes | GID_test@@@producer | The client ID of the device whose traces you want to query. |
BeginTime | Long | Yes | 1621580400000 | The beginning of the time range to query. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC. Unit: milliseconds. |
EndTime | Long | Yes | 1621584000000 | The end of the time range to query. This value is a UNIX timestamp representing the number of milliseconds that have elapsed since the epoch time January 1, 1970, 00:00:00 UTC. Unit: milliseconds. |
CurrentPage | Integer | Yes | 1 | 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. |
PageSize | Integer | Yes | 5 | The number of entries to return on each page. Valid values: 1 to 100. |
Reverse | Boolean | Yes | false | Specifies whether the returned results are displayed in reverse chronological order. Valid values:
The default value : false. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 317076B7-F946-46BC-A98F-4CF9777C**** | The ID of the request. This parameter is a common parameter. Each request has a unique ID, which facilitates troubleshooting and problem locating. |
Total | Long | 3 | The total number of entries returned. |
CurrentPage | Integer | 1 | The page number of the returned page. |
PageSize | Integer | 2 | The number of entries returned per page. |
DeviceInfoList | Array of DeviceInfoList | The details about an entry. | |
Action | String | connect | The action on the device. Valid values:
|
ActionCode | String | mqtt.trace.action.connect | The code returned for the action on the device. Valid values:
|
ActionInfo | String | accept | The information returned for the action on the device. Valid values:
|
ChannelId | String | c69fe839209547fa9d073781b9cd**** | The ID of a connection. |
Time | String | 2021-05-21 15:51:54.867 | The time when the action occurred on the device. |
Examples
Sample requests
http(s)://onsmqtt.cn-hangzhou.aliyuncs.com/?Action=QueryMqttTraceDevice
&MqttRegionId=cn-hangzhou
&InstanceId=mqtt-cn-i7m26mf****
&ClientId=GID_test@@@producer
&BeginTime=1621580400000
&EndTime=1621584000000
&CurrentPage=1
&PageSize=5
&Reverse=false
&<Common request parameters>
Sample success responses
XML
format
<QueryMqttTraceDeviceResponse>
<DeviceInfoList>
<Action>connect</Action>
<ActionCode>mqtt.trace.action.connect</ActionCode>
<ActionInfo>accepted</ActionInfo>
<Time>2021-05-21 15:10:21.844</Time>
<ChannelId>27e1c09a1d7d4944901500db7186****</ChannelId>
</DeviceInfoList>
<DeviceInfoList>
<Action>close</Action>
<ActionCode>mqtt.trace.action.close</ActionCode>
<ActionInfo>no heart</ActionInfo>
<Time>2021-05-21 15:51:37.980</Time>
<ChannelId>27e1c09a1d7d4944901500db7186****</ChannelId>
</DeviceInfoList>
<DeviceInfoList>
<Action>connect</Action>
<ActionCode>mqtt.trace.action.connect</ActionCode>
<ActionInfo>accepted</ActionInfo>
<Time>2021-05-21 15:52:48.669</Time>
<ChannelId>34022074d3c1403faba6e0334121****</ChannelId>
</DeviceInfoList>
<PageSize>5</PageSize>
<CurrentPage>1</CurrentPage>
<Total>3</Total>
<RequestId>317076B7-F946-46BC-A98F-4CF9777C****</RequestId>
</QueryMqttTraceDeviceResponse>
JSON
format
{
"DeviceInfoList": [
{
"Action": "connect",
"ActionCode": "mqtt.trace.action.connect",
"ActionInfo": "accepted",
"Time": "2021-05-21 15:10:21.844",
"ChannelId": "27e1c09a1d7d4944901500db7186****"
},
{
"Action": "close",
"ActionCode": "mqtt.trace.action.close",
"ActionInfo": "no heart",
"Time": "2021-05-21 15:51:37.980",
"ChannelId": "27e1c09a1d7d4944901500db7186****"
},
{
"Action": "connect",
"ActionCode": "mqtt.trace.action.connect",
"ActionInfo": "accepted",
"Time": "2021-05-21 15:52:48.669",
"ChannelId": "34022074d3c1403faba6e0334121****"
}
],
"PageSize": 5,
"CurrentPage": 1,
"Total": 3,
"RequestId": "317076B7-F946-46BC-A98F-4CF9777C****"
}
Error codes
HttpCode | Error code | Error message | Description |
---|---|---|---|
500 | SystemOverFlow | An error occurred while processing your request. Please try again. | The error message returned because throttling is triggered by the system. Try again later. |
404 | ApiNotSupport | The specified API operation is not supported. | The error message returned because the API operation is not supported. |
For a list of error codes, visit the API Error Center.
Operations in the ApsaraMQ for MQTT console
In addition to calling the QueryMqttTraceDevice operation, you can also view device traces in the ApsaraMQ for MQTT console. For more information, see Query device traces.