keep alive mqtt option
See original GitHub issueHi,
Using aws-iot-device-sdk npm package (version 2.2.1) for publishing data to cloud. NodeJS application (mqtt client) code publishes data to cloud.
device = awsIot.device({
keyPath: process.env.AWS_MQTT_KEY,
certPath: process.env.AWS_MQTT_CERT,
caPath: process.env.AWS_MQTT_ROOTCA,
clientId: process.env.AWS_MQTT_CLIENT_ID,
region: process.env.AWS_MQTT_REGION,
host: process.env.AWS_MQTT_HOST,
offlineQueueMaxSize: parseInt(process.env.AWS_MQTT_OFFLINE_QUEUE_MAX_SIZE),
offlineQueueDropBehavior: process.env.AWS_MQTT_OFFLINE_QUEUE_DROP_BEHAVIOR,
maximumReconnectTimeMs: parseInt(process.env.AWS_MQTT_MAX_RECONNECT_TIME_MSEC),
keepalive: parseInt(process.env.AWS_MQTT_KEEPALIVE_SEC)
});
- Disabled keepalive option (keepalive = 0, ping disabled), so as per the AWS IoT documentation (https://docs.aws.amazon.com/general/latest/gr/aws_service_limits.html#limits_iot )
" For MQTT (or MQTT over WebSockets) connections, a client can request a keep-alive interval between 30 - 1200 seconds as part of the MQTT CONNECT message. AWS IoT starts the keep-alive timer for a client when sending CONNACK in response to the CONNECT message. This timer is reset whenever AWS IoT receives a PUBLISH, SUBSCRIBE, PING, or PUBACK message from the client. AWS IoT will disconnect a client whose keep-alive timer has reached 1.5x the specified keep-alive interval (i.e., by a factor of 1.5).The default keep-alive interval is 1200 seconds. If a client requests a keep-alive interval of zero, the default keep-alive interval will be used. If a client requests a keep-alive interval greater than 1200 seconds, the default keep-alive interval will be used. If a client requests a keep-alive interval shorter than 30 seconds but greater than zero, the server treats the client as though it requested a keep-alive interval of 30 seconds. "
default keepalive interval i.e. 1200 seconds should be used and after every publish the timer resets right?
NodeJS application (mqtt client) publishes data every 5 minutes for the first 5 times and after that publishes data every 15 minutes but first 5 published was successful, after that even though application was publishing data never reached to cloud (AWS IoT). I think AWS IoT timer was never reset because there was no two way data flow (MQTT client <-> AWS IoT)? else let us know what the issue is?
- When keepalive is enabled (for ex: keepalive = 300 seconds) then NodeJS application publishes data without any issues because mqtt client send ping requests and receives ping response from the AWS IoT (broker), correct?
Looking forward to hearing from you soon!!
Thanks in advance, Gautham
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (2 by maintainers)

Top Related StackOverflow Question
Happy to help 👍
Oh ok, that’s what I thought. Thanks for the responses, appreciated!!