调用QuerySessionByClientId根据Client ID查询指定设备的连接信息。

使用场景

QuerySessionByClientId接口一般用于线上追踪单个设备的运行状态,再根据查询到的信息排查问题。输入Client ID即可查到对应设备是否在线、设备地址等信息。

Client ID的详细信息,请参见名词解释

使用限制

QuerySessionByClientId接口的QPS限制为500。更多信息请参见QPS限制

说明 每成功调用一次QuerySessionByClientId接口,都会计算为一次消息TPS,从而影响您的计费。详情请参见计费说明

调试

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

请求参数

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

系统规定参数。取值:QuerySessionByClientId

ClientId String GID_test@@@test

需要查询的目标Client ID。

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

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

说明 更多参数说明请参见公共参数服务接入点

返回数据

名称 类型 示例值 描述
OnlineStatus Boolean true

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

  • true:在线
  • false:不在线
RequestId String E4581CCF-62AF-44D9-B5B4-D1DBBC0E****

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

示例

请求示例

http(s)://onsmqtt.cn-hangzhou.aliyuncs.com/?Action=QuerySessionByClientId
&ClientId=GID_test@@@test
&InstanceId=post-cn-0pp12gl****
&RegionId=cn-hangzhou
&<公共请求参数>

正常返回示例

XML格式

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

<QuerySessionByClientIdResponse>
      <OnlineStatus>true</OnlineStatus>
      <RequestId>E4581CCF-62AF-44D9-B5B4-D1DBBC0E****</RequestId>
</QuerySessionByClientIdResponse>

JSON格式

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

{
  "OnlineStatus" : true,
  "RequestId" : "E4581CCF-62AF-44D9-B5B4-D1DBBC0E****"
}

错误码

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. 当前接口不支持,请检查。

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