You can call this operation to query the number of connected Message Queue for MQTT (MQTT) clients in a group based on the specified group ID.


OnsMqttQueryClientByGroupId is typically used for service analysis and used to query statistics on the activity level of the devices that correspond to the specified group ID.

API operations are designed for you to implement custom management and development. Based on this, the MQTT broker throttles frequent calls that amount to 30 or more per minute. Therefore, do not call this operation in the main service process.


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

Request parameters

Parameter Type Required Example Description
Action String Yes OnsMqttQueryClientByGroupId

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

GroupId String Yes GID_test

The group ID that you want to query.

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

The ID of the MQTT instance to which the group ID you want to query belongs. This parameter is required for instances with separate namespaces.

Response parameters

Parameter Type Example Description

The structure of information about whether the MQTT clients in the group were connected.

OnlineCount Long 1

The total number of connected MQTT clients in the group.

RequestId String E54CBFC3-7700-44BC-8FFA-B61E471D4876

The ID of the request, which is a common parameter. Each request has a unique ID to facilitate troubleshooting and fault locating.


Sample request

http(s)://[Endpoint]/? Action=OnsMqttQueryClientByGroupId
&<Common request parameters>

Sample success response

XML format


JSON format


Error codes

For a list of error codes, visit the API Error Center.