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
|
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
|
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
4. Authentication and authorization: The username and password must be valid, and the account must have the CONNECT permission.
5. HTTP response:
|
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. |