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. |
curl --header "Authorization: Basic dXNlcjA6c2VjcmV0MA==" https://${instance-access-point}/client-id/${client-id}/status
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 |
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. |
{"online":true}
Parameter | Description |
online | Client Online Status. true: online. false: offline. |
Feedback