调用BatchQuerySessionByClientIds根据Client ID批量查询客户端在线状态。

使用限制

  • BatchQuerySessionByClientIds接口的QPS为100。更多信息,请参见QPS限制
  • 每次调用BatchQuerySessionByClientIds接口最多查询10个Client ID对应的客户端的在线状态。
说明 每成功调用一次BatchQuerySessionByClientIds接口,都会计算为一次消息TPS,从而影响您的计费。计费详情,请参见计费说明

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称 类型 是否必选 示例值 描述
Action String BatchQuerySessionByClientIds

系统规定参数。取值:BatchQuerySessionByClientIds

InstanceId String post-cn-0pp12gl****

云消息队列 MQTT 版实例的ID,一定要和客户端实际使用的实例ID匹配。您可以在控制台实例详情页面获取该ID。

ClientIdList.N String ClientIdList.1

客户端编号,表示第N个Client ID。

说明 单次最多批量查询10个Client ID的状态,即N的取值范围为1~10。
说明 更多参数说明请参见公共参数服务接入点

返回数据

名称 类型 示例值 描述
RequestId String 63309FDB-ED6C-46AE-B31C-A172FBA0****

公共参数,每个请求的ID都是唯一的。

OnlineStatusList Array of OnlineStatusList

客户端状态列表。

OnlineStatus Boolean true

设备是否在线,取值说明如下:

  • true:在线
  • false:不在线
ClientId String GID_test@0001

客户端的Client ID。Client ID的详细信息,请参见名词解释

示例

请求示例

http(s)://onsmqtt.cn-hangzhou.aliyuncs.com/?Action=BatchQuerySessionByClientIds
&ClientIdList.1=ClientIdList.1
&InstanceId=post-cn-0pp12gl****
&RegionId=cn-hangzhou
&<公共请求参数>

正常返回示例

XML格式

HTTP/1.1 200 OK
Content-Type:application/xml

<BatchQuerySessionByClientIdsResponse>
  <OnlineStatusList>
        <ClientId>GID_test@0001</ClientId>
        <OnlineStatus>true</OnlineStatus>
  </OnlineStatusList>
  <OnlineStatusList>
        <ClientId>GID_test@0002</ClientId>
        <OnlineStatus>false</OnlineStatus>
  </OnlineStatusList>
  <RequestId>63309FDB-ED6C-46AE-B31C-A172FBA0****</RequestId>
</BatchQuerySessionByClientIdsResponse>

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "OnlineStatusList" : [ {
    "ClientId" : "GID_test@0001",
    "OnlineStatus" : true
  }, {
    "ClientId" : "GID_test@0002",
    "OnlineStatus" : false
  } ],
  "RequestId" : "63309FDB-ED6C-46AE-B31C-A172FBA0****"
}

错误码

HttpCode 错误码 错误信息 描述
400 CheckAccountInfoFailed An error occurred while checking the account information by the STS token. 解析 STS Token 账号信息失败。
400 InstancePermissionCheckFailed An error occurred while validating the permissions of the instance. Please verify the account that created the instance and its permissions settings. 实例权限校验失败,请确认 MQTT 实例的所属关系以及授权策略。
400 ParameterCheckFailed An error occurred while validating the parameters. The parameters may be missing or invalid. 参数校验失败,可能缺失或者传入值非法。
400 PermissionCheckFailed An error occurred while validating the resource permissions. Please check the account that created the instance, topic, and GroupId, and check their permission settings. 资源权限校验失败,请检查实例、Topic 和 Group ID 的所属权限和授权策略。
400 InvalidParameter.%s An error occurred while validating the parameter. The parameter may be missing or invalid. 参数校验失败,可能缺失或者传入值非法。
500 InternalError An error occurred while processing your request. Try again later. MQTT 后端服务异常,请重试。
500 SystemOverFlow An error occurred while processing your request. Please try again. 系统限流,请重试。
404 ApiNotSupport The specified API is not supported. 当前接口不支持,请检查。

访问错误中心查看更多错误码。