Forum Discussion
IoT Hub Device twin returning connectionState = Disconnected, when it's actually connected
- 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
asergaz Hi, this is out of the subject, but how could we change the connection state programmatically. Also status of device.
Nagnath 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 :)!