tencent cloud

TDMQ for MQTT

Release Notes and Announcements
Release Notes
Product Introduction
TDMQ Product Series Introduction and Selection
What Is TDMQ for MQTT
Scenarios
Technical Architecture
Product series
MQTT Protocol Compatibility Notes
Comparison with Apache
High Availability
Product Constraints and Usage Quota
Basic Concepts
Supported Regions
Billing
Billing Overview
Renewal Instructions
Viewing Consumption Details
Overdue Payment Instructions
Refund
Getting Started
Guide for Getting Started
Preparations
Public Network Access
VPC Network Access
User Guide
Usage Process Guide
Configuring Account Permission
Creating a Cluster
Managing Topic
Connecting to the Cluster
Querying Messages
Managing Client
Managing a Cluster
Viewing Monitoring Metrics and Configuring Alarm Policies
Data Integration
Integrating Data Into SCF
Integrating Data Into CKafka
Integrating Data into RocketMQ
Development Guide
MQTT 5 Advanced Features
Data Plane HTTP API Description
Quota and Flow Control Mechanism Description
Configuring a Custom Domain Name
Configuring SQL Filtering
Configuring Point-to-Point Subscription
MQTT over QUIC
Managing Client Subscription
Message Enhancement Rule
Use Cases
Must-Knows for MQTT Client Development
Observability
Topic and Wildcard Subscriptions
​​API Reference
History
Introduction
API Category
Making API Requests
Cluster APIs
Topic APIs
Authorization Policy APIs
User APIs
Client APIs
Message Enhancement Rule APIs
Message APIs
Data Types
Error Codes
SDK Reference
Access Point Format
Java SDK
C SDK
Javascript/Node.JS/Mini Program
Go SDK
iOS SDK
JavaScript SDK
Dart SDK
Python SDK
.NET
Security and Compliance
Permission Management
FAQs
Related Agreement
Privacy Policy
Data Privacy And Security Agreement
TDMQ for MQTT Service Level Agreement
Contact Us

Querying Client Online Status

PDF
フォーカスモード
フォントサイズ
最終更新日: 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.

ヘルプとサポート

この記事はお役に立ちましたか?

フィードバック