Queries the messages of a specified device.
Billing
Each successful call to the QueryMqttTraceMessageOfClient 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 | QueryMqttTraceMessageOfClient | The operation that you want to perform. Set the value to QueryMqttTraceMessageOfClient. |
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 messages you want to query. |
BeginTime | Long | Yes | 1618646400000 | 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 | 1621591200000 | 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 | No | false | Specifies whether the returned results are displayed in reverse chronological order. Valid values:
If this parameter is not specified, the returned results are displayed in order of the time when the message is sent or consumed. |
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | B096B9D6-62F3-4567-BB59-58D1362E**** | 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 | 5 | The total number of messages returned. |
CurrentPage | Integer | 1 | The page number of the returned page. |
PageSize | Integer | 10 | The number of entries returned per page. |
MessageOfClientList | Array of MessageOfClientList | The returned messages. | |
Action | String | pub_mqtt | The action on the message. Valid values:
|
ActionCode | String | mqtt.trace.action.msg.pub.mqtt | The code returned for the action on the message. Valid values:
|
ActionInfo | String | Pub From Mqtt Client | The information returned for the action on the message. Valid values:
|
ClientId | String | GID_test@@@producer | The client ID of the device. |
MsgId | String | AC1EC0030EAB78308DB16A3EC773**** | The ID of the message. |
Time | String | 2021-05-21 15:08:19.234 | The time when the message was sent or consumed. |
Examples
Sample requests
http(s)://onsmqtt.cn-hangzhou.aliyuncs.com/?Action=QueryMqttTraceMessageOfClient
&MqttRegionId=cn-hangzhou
&InstanceId=mqtt-cn-i7m26mf****
&ClientId=GID_test@@@producer
&BeginTime=1618646400000
&EndTime=1621591200000
&CurrentPage=1
&PageSize=5
&<Common request parameters>
Sample success responses
XML
format
<QueryMqttTraceMessageOfClientResponse>
<RequestId>B096B9D6-62F3-4567-BB59-58D1362E****</RequestId>
<PageSize>10</PageSize>
<CurrentPage>1</CurrentPage>
<Total>5</Total>
<MessageOfClientList>
<Action>pub_mqtt</Action>
<ActionCode>mqtt.trace.action.msg.pub.mqtt</ActionCode>
<ClientId>GID_test@@@producer</ClientId>
<ActionInfo>Pub From Mqtt Client</ActionInfo>
<Time>2021-05-21 15:08:19.210 </Time>
<MsgId>AC1EC0030EAB78308DB16A3EC773****</MsgId>
</MessageOfClientList>
<MessageOfClientList>
<Action>pub_mqtt</Action>
<ActionCode>mqtt.trace.action.msg.pub.mqtt</ActionCode>
<ClientId>GID_test@@@producer</ClientId>
<ActionInfo>Pub From Mqtt Client</ActionInfo>
<Time>2021-05-21 15:08:19.234 </Time>
<MsgId>AC1EC0030EAB78308DB16A3EC78F****</MsgId>
</MessageOfClientList>
<MessageOfClientList>
<Action>pub_mqtt</Action>
<ActionCode>mqtt.trace.action.msg.pub.mqtt</ActionCode>
<ClientId>GID_test@@@producer</ClientId>
<ActionInfo>Pub From Mqtt Client</ActionInfo>
<Time>2021-05-21 15:08:19.234 </Time>
<MsgId>AC1EC0030EAB78308DB16A3EC78F****</MsgId>
</MessageOfClientList>
<MessageOfClientList>
<Action>pub_mqtt</Action>
<ActionCode>mqtt.trace.action.msg.pub.mqtt</ActionCode>
<ClientId>GID_test@@@producer</ClientId>
<ActionInfo>Pub From Mqtt Client</ActionInfo>
<Time>2021-05-21 15:08:19.234 </Time>
<MsgId>AC1EC0030EAB78308DB16A3EC78F****</MsgId>
</MessageOfClientList>
<MessageOfClientList>
<Action>pub_mqtt</Action>
<ActionCode>mqtt.trace.action.msg.pub.mqtt</ActionCode>
<ClientId>GID_test@@@producer</ClientId>
<ActionInfo>Pub From Mqtt Client</ActionInfo>
<Time>2021-05-21 15:08:19.234 </Time>
<MsgId>AC1EC0030EAB78308DB16A3EC78F****</MsgId>
</MessageOfClientList>
</QueryMqttTraceMessageOfClientResponse>
JSON
format
{
"RequestId": "B096B9D6-62F3-4567-BB59-58D1362E****",
"PageSize": 10,
"CurrentPage": 1,
"Total": 5,
"MessageOfClientList": [
{
"Action": "pub_mqtt",
"ActionCode": "mqtt.trace.action.msg.pub.mqtt",
"ClientId": "GID_test@@@producer",
"ActionInfo": "Pub From Mqtt Client",
"Time": "2021-05-21 15:08:19.210 ",
"MsgId": "AC1EC0030EAB78308DB16A3EC77****"
},
{
"Action": "pub_mqtt",
"ActionCode": "mqtt.trace.action.msg.pub.mqtt",
"ClientId": "GID_test@@@producer",
"ActionInfo": "Pub From Mqtt Client",
"Time": "2021-05-21 15:08:19.234 ",
"MsgId": "AC1EC0030EAB78308DB16A3EC78F****"
},
{
"Action": "pub_mqtt",
"ActionCode": "mqtt.trace.action.msg.pub.mqtt",
"ClientId": "GID_test@@@producer",
"ActionInfo": "Pub From Mqtt Client",
"Time": "2021-05-21 15:08:19.234 ",
"MsgId": "AC1EC0030EAB78308DB16A3EC78F****"
},
{
"Action": "pub_mqtt",
"ActionCode": "mqtt.trace.action.msg.pub.mqtt",
"ClientId": "GID_test@@@producer",
"ActionInfo": "Pub From Mqtt Client",
"Time": "2021-05-21 15:08:19.234 ",
"MsgId": "AC1EC0030EAB78308DB16A3EC78F****"
},
{
"Action": "pub_mqtt",
"ActionCode": "mqtt.trace.action.msg.pub.mqtt",
"ClientId": "GID_test@@@producer",
"ActionInfo": "Pub From Mqtt Client",
"Time": "2021-05-21 15:08:19.234 ",
"MsgId": "AC1EC0030EAB78308DB16A3EC78F****"
}
]
}
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 QueryMqttTraceMessageOfClient operation, you can also view the messages of a device in the ApsaraMQ for MQTT console. For more information, see Query message traces.