Reputation: 93
So my issue is rather simple in all honesty. I'm trying to see if there is a way to trigger Lifecycle Events within AWS IoT much quicker. So far my code is as follows on connect:
mqttc.connect(aws_iot_endpoint, port=443, keepalive=1)
The value for keepalive cannot be lower than 1, as it's not enough time for the thing to connect to AWS. When connection to the device is lost it takes approximately 7 to 8 seconds for AWS IoT to send out this message:
MQTT_KEEP_ALIVE_TIMEOUT
I was wondering if there is any way to decrease that time even further? Is using AWS IoT Events the way forward?
Upvotes: 1
Views: 1238
Reputation: 1018
Keep Alive cannot be set to 1 sec per AWS docs. Values less than 30 are set to 30.
The default keep-alive interval is 1200 seconds. It is used when a client requests a keep-alive interval of zero. If a client requests an interval > 1200 seconds, the default interval is used. If a client requests a keep-alive interval < 30 seconds but > zero, the server treats the client as though it requested a keep-alive interval of 30 seconds.
Upvotes: 0
Reputation: 23602
If your keep-alive is set to 1 second, then MQTT_KEEP_ALIVE_TIMEOUT
should be 1.5x which is 1.5 seconds, not 7-8 seconds.
Make sure that you're also setting your ping timeout (in ms) to a value shorter than 1000ms as otherwise, AWS may just default to 3 seconds for ping timeout.
Upvotes: 1