tencent cloud

Querying Client Online Status
Last updated:2026-01-30 14:59:40
Querying Client Online Status
Last updated: 2026-01-30 14:59:40

Overview

TDMQ for MQTT supports getting MQTT client online status through query and client event.

Technical Principles

TDMQ for MQTT provides two methods to query client online status:
Method
Description
Use Cases
Difference Comparison
Query
The instance provides a RESTful API for real-time query of client online status.
1. The business process needs to determine the subsequent logic based on whether the client is online.
2. Check whether a specific client is currently online during the Ops process.
Active query checks the real-time status of the current client, which is more accurate compared with the notification method for user login or logout.

Client event
Use notifications. When client login or logout events are triggered, the MQTT server generates corresponding events and publishes them to the system theme. Business applications can subscribe to related event messages as needed.
This method belongs to asynchronous perception of client state and perceives user login or logout events rather than online status. Cloud applications need to analyze the client state based on the time sequence of event occurrence.
1. Business needs trigger some predefined actions when clients go live or offline.
2. Business needs perform statistical analysis on client login or logout data and push messages based on client online status.
Clients use message decoupling, making status judgment more complex with a higher likelihood of misjudgment (final consistency). Although there is certain complexity and probability of false positives, it is more suitable for large-scale client status statistics.

Usage

Query

Query
Client Event

Request Example

Query through the following RESTful API:
curl --header "Authorization: Basic dXNlcjA6c2VjcmV0MA==" https://${instance-access-point}/client-id/${client-id}/status
Request Parameters
Variables
Semantics
Example Value
${instance-access-point}
The instance endpoint address can be obtained from the Cluster > Basic Info page in the console.
mqtt-xxxx-gz-public.mqtt.tencenttdmq.com
${client-id}
The target client-id you want to query. For standard definition, see
Client Identifier (ClientID). The result needs to be URL encoded.
VIN0000001

Status Code Description

1. Support HTTP Method: GET/POST.
2. Support HTTP/HTTPS.
3. Authenticate via HTTP Basic Authentication. See Basic Authentication.
4. Authentication and authorization: The username and password must be valid, and the account must have CONNECT permission.
5. HTTP response:
HTTP Status Code
Description
200
The request is successful.
401
Authentication failed. Username or password is incorrect.
403
Authentication failure, lack of CONNECT permission.
429
Flow control, Too Many Requests.

Output Example

If the request is successful, return the following content:
{"online":true}
Output Parameter Description
Parameter
Description
online
Client Online Status.
true: online.
false: offline.
For details, see Query Client Events.

Billing Overview

Querying the online status of a client is equivalent to publishing a message with QoS=0. For details, see Billing Overview. The query frequency is subject to the instance QPS Quota limit.
Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback