Forum Discussion
smart_door
Dec 26, 2018Brass Contributor
IoT Hub Device twin returning connectionState = Disconnected, when it's actually connected
I have a Monitoring web job that querys my iot devices for any that have a connection state = disconnected, and then sends an email out to the user of that device to let them know it has a connection...
- Dec 31, 2018
Hi!
You should have a look here: Device heartbeat
"
The IoT Hub identity registry contains a field called connectionState. Only use the connectionState field during development and debugging. IoT solutions should not query the field at run time. For example, do not query the connectionState field to check if a device is connected before you send a cloud-to-device message or an SMS. We recommend subscribing to the device disconnected event on Event Grid to get alerts and monitor the device connection state. Use this tutorial to learn how to integrate Device Connected and Device Disconnected events from IoT Hub in your IoT solution.
"
Hope that helps!
Thanks
Nagnath
Nov 26, 2019Copper Contributor
asergaz Hi, this is out of the subject, but how could we change the connection state programmatically. Also status of device.
asergaz
Microsoft
Nov 26, 2019Nagnath hi. You can use the azure iot sdk and give a look at how to manipulate device twin here.
Open a new post if you have further questions. Thanks :)!