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

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

ParameterTypeRequiredExampleDescription
ActionStringYesQueryMqttTraceMessageOfClient

The operation that you want to perform. Set the value to QueryMqttTraceMessageOfClient.

MqttRegionIdStringYescn-hangzhou

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

InstanceIdStringYesmqtt-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.

ClientIdStringYesGID_test@@@producer

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

BeginTimeLongYes1618646400000

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.

EndTimeLongYes1621591200000

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.

CurrentPageIntegerYes1

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.

PageSizeIntegerYes5

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

ReverseBooleanNofalse

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

  • true: The returned results are displayed in reverse order of the time when the message is sent or consumed. This means that the last sent or consumed message is displayed as the first entry and that the earliest sent or consumed message is displayed as the last entry.
  • false: The returned results are displayed in order of the time when the message is sent or consumed. This means that the earliest sent or consumed message is displayed as the first entry and that the last sent or consumed message is displayed as the last entry.

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

ParameterTypeExampleDescription
RequestIdStringB096B9D6-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.

TotalLong5

The total number of messages returned.

CurrentPageInteger1

The page number of the returned page.

PageSizeInteger10

The number of entries returned per page.

MessageOfClientListArray of MessageOfClientList

The returned messages.

ActionStringpub_mqtt

The action on the message. Valid values:

  • pub_mqtt: The ApsaraMQ for MQTT client sends the message.
  • sub: The ApsaraMQ for MQTT client subscribes to the message.
  • push_offline: The ApsaraMQ for MQTT broker pushes the offline message to the ApsaraMQ for MQTT client.
ActionCodeStringmqtt.trace.action.msg.pub.mqtt

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

  • mqtt.trace.action.msg.pub.mqtt: This parameter value is returned if the value of the Action parameter is pub_mqtt.
  • mqtt.trace.action.msg.sub: This parameter value is returned if the value of the Action parameter is sub.
  • mqtt.trace.action.msg.push.offline: This parameter value is returned if the value of the Action parameter is push_offline.
ActionInfoStringPub From Mqtt Client

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

  • Pub From Mqtt Client: This parameter value is returned if the value of the Action parameter is pub_mqtt.
  • Push To Mqtt Client: This parameter value is returned if the value of the Action parameter is sub.
  • Push Offline Msg To Mqtt Client: This parameter value is returned if the value of the Action parameter is push_offline.
ClientIdStringGID_test@@@producer

The client ID of the device.

MsgIdStringAC1EC0030EAB78308DB16A3EC773****

The ID of the message.

TimeString2021-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

HttpCodeError codeError messageDescription
500SystemOverFlowAn error occurred while processing your request. Please try again.The error message returned because throttling is triggered by the system. Try again later.
404ApiNotSupportThe 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.