Improvement of MQTT sas token renewal #1830
Replies: 2 comments 2 replies
-
I didn't make the decision, but my guess is that a SAS token is good for the specified duration, and seems to continue to work even if the symmetric key that it was generated from is recycled. Keeping it at 60 minutes seems to be a reasonable compromise between not generating a SAS token too often, but also kicking off a device from a hub when the symmetric key is revoked without waiting too long. The version of MQTT we use simply disconnects clients after the SAS token has expired, as opposed to AMQP. I thought it was worth noting that part of the behavior appears to be related to this MQTT version. We can't change the default now as the change in behavior could impact other customers. If you wish, there is a way to provide your own implementation to increase the duration of the SAS token's TTL. I can't remember it off-hand and will get back to you on that. |
Beta Was this translation helpful? Give feedback.
-
Thank you for your reply. I'll have a look at it. |
Beta Was this translation helpful? Give feedback.
-
Currently using the Iot DeviceSdk DeviceClient with MQTT leads to a reconnect every ~60 minutes due to the way the sas token renewal is implemented. This also causes frequent calls of ConnectionStatusChanges handler and also error logs.
So device developers using the sdk will always have to filter the connection change reason and decide if they are "exceptional" or just caused by a "planned" sas token renewal.
https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-troubleshoot-connectivity#mqtt-device-disconnect-behavior-with-azure-iot-sdks
I wonder why Microsoft choose to implement it like that and if there are any attempts to change this behavior in future?
Update:
In the meantime i found this old github issue which relates to the topic. Seems like there are no plans to change the behavior anytime soon :(
Azure/azure-iot-sdk-java#316
Beta Was this translation helpful? Give feedback.
All reactions