Forum Discussion

smart_door's avatar
smart_door
Brass Contributor
Dec 26, 2018
Solved

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...
  • asergaz's avatar
    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

Resources