tencent cloud

TDMQ for MQTT

Dynamically Modifying Client Keep Alive Time

PDF
聚焦模式
字号
最后更新时间: 2026-04-01 16:37:51

Overview

This API dynamically adjusts the Keep Alive (heartbeat) time for online MQTT clients. After this API is called, the server immediately applies the new Keep Alive time without disconnecting the client.

Usage Method

curl --verbose --request POST -H "Authorization: Basic base64(username:password)" http://mqtt.cloud.tencent.com/keep-alive?client-id=${client-id}&interval=${seconds}

Authentication Method

Two authentication methods are supported: Basic HTTP Authentication and X.509 certificate-based one-device-one-certificate authentication. JWT-based authentication is not yet supported.

Basic HTTP Authentication

The Basic Authentication parameters are described below:
The HTTP request header contains an Authorization field in the following format: Authorization: Basic <credentials>
<credentials> = username:password in Base64 encoding.
username is used for ACL authorization.

BYOC (X.509 Certificate-Based One-Device-One-Certificate Authentication)

Root certificate trusted by clients: CA.crt
Client certificate chain file: client.chain.crt
Client private key file: client.pkcs8.key

Request Parameters

Parameter Name
Required
Type
Description
client-id
Yes
String
Client ID
interval
Yes
Integer
New Keep Alive time, ranging from 30 to 1200 (unit: seconds)
Note:
The following limitations apply when calling this API:
Sessions with Keep Alive set to 0 cannot be modified: If the client sets Keep Alive to 0 during connection, this API cannot modify it.
Keep Alive cannot be set to 0: This API does not allow setting the Keep Alive time of existing connections to 0.

Response Parameters

Parameter Name
Type
Description
success
Boolean
Request processing result. true indicates success.
keepalive
Integer
Keep Alive time after modification, in seconds.

Request Example

Example 1

Using Basic Authentication
curl --request POST \\
--header "Authorization: Basic c2Vpcm9saTIyMjo5NEZWUmpTejBOR0dXVmFU" \\
"http://mqtt.cloud.tencent.com/keep-alive?client-id=curl-x&interval=120"

Example 2

Using BYOC Certificate Authentication
curl --tlsv1.2 \\
--cacert CA.crt \\
--cert client.chain.crt \\
--key client.pkcs8.key \\
--verbose \\
--request POST \\
"https://mqtt.cloud.tencent.com/keep-alive?client-id=curl-x&interval=120"

Response Example

Successful Response Example

{
"success": true,
"keepalive": 120
}

Status Code Description

1. Supported HTTP method: POST.
2. Supported protocols: HTTP/HTTPS
3. Authentication: via HTTP Basic Authentication or BYOC. 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
Request successful.
401
Authentication failed. Invalid username or password.
403
Authorization failed. The account lacks CONNECT permission.
429
Flow control, with too many requests.



帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈