question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

keep alive mqtt option

See original GitHub issue

Hi,

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)
		});

  1. 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?

  1. 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:closed
  • Created 5 years ago
  • Comments:11 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ColdenCullencommented, Feb 8, 2019

Happy to help 👍

0reactions
gauthamkantharajucommented, Feb 8, 2019

Oh ok, that’s what I thought. Thanks for the responses, appreciated!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is the MQTT Keep Alive parameter for? - EMQ
Keep Alive is an integer from 0 to 65535, representing the maximum time in seconds allowed to elapse between MQTT protocol packets sent...
Read more >
MQTT Keep Alive Interval Explained With Examples
MQTT uses a keepalive mechanism for checking the status of the TCP/IP connection.On a quiet TCP/IP connection an MQTT client will send a ......
Read more >
Keep Alive and Client Take-Over - MQTT Essentials Part 10
Keep alive ensures that the connection between the broker and client is still open and that the broker and the client are aware...
Read more >
Introduction to MQTT: Chapter 7 (Keep Alive & Client Takeover)
The keep alive interval is a numeric value that indicates the number of seconds that a client can be dormant and still considered...
Read more >
Unlimited keepalive in MQTT - Stack Overflow
MQTT clients can stay connected indefinitely even if they do not publish or receive any messages. But the broker needs to keep track...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found