Azure / iot-central-firmware

Azure IoT Device Samples ✨ 📟 🔌 🔋💡 ✨
Other
128 stars 96 forks source link

Renew the SAS token and reconnect automatically #111

Open zishanyang opened 4 years ago

zishanyang commented 4 years ago

iotc - Azure IoT Central - Python (light) device SDK https://pypi.org/project/iotc/

I'm using above for my Raspberry PI to connect to Azure IoT central SaaS. It has a expiration for SAS token, which can be managed as device.setTokenExpiration(totalSeconds). However, in case of token expired, the program will exit, and the re-connection won't work since the token has expired does not accept any more commands(e.g iotc.disconnect() ). How to make sure the device can always connect? Can we set token to No expiration? if not, is there a way to renew the token or recycle the old client instance so the device can reconnect?

dmitriyteteruk commented 4 years ago

code should work fine and do re-connect. Here is similar case with same code and author found error in his app logic.