tencent cloud

TDMQ for MQTT

Related Agreement
개인 정보 보호 정책
데이터 개인 정보 보호 및 보안 계약
문서TDMQ for MQTT

Querying Client Online Status

포커스 모드
폰트 크기
마지막 업데이트 시간: 2026-04-01 16:37:50

Overview

TDMQ for MQTT supports obtaining the MQTT client online status through active query and client event.

Principles

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

Client Event
Using message 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 means asynchronous perception of the client status, and what is perceived are login or logout events rather than the online status. Cloud applications need to analyze the client status based on the time sequence of the events.
1. The business needs to trigger some predefined actions upon client login or logout.
2. The business needs to perform statistical analysis on client login or logout data and push messages based on the client online status.
Clients use message decoupling, making status judgment more complex with a higher likelihood of misjudgment (in terms of final consistency). Although there is certain complexity and probability of misjudgment, it is more suitable for large-scale client status statistics.

Usage Method

Active Query

Active 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 parameter description
Variables
Semantics
Example Value
${instance-access-point}
The instance access point address, which 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 the 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 the CONNECT permission.
5. HTTP response:
HTTP Status Code
Description
200
The request is successful.
401
Authentication failed. The username or password is incorrect.
403
Authorization failed. The account lacks CONNECT permission.
429
Flow control, with 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 Instructions

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.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백