How to know whether our IoTedge device is connected to IoTHub from the python sdk or any command other pinging to Host

Athira Gopinath(UST,IN) 101 Reputation points
2025-01-16T12:14:01.2766667+00:00

Hi Team,

As part of our R&D, we are attempting to determine whether our IoT Edge Device is successfully connecting to IoT Hub. Currently, we are trying to ping the IoT Hub. Are there alternative methods to verify if the IoT Edge Device is connected to the IoT Hub? Please suggest potential solutions.

Azure IoT Edge
Azure IoT Edge
An Azure service that is used to deploy cloud workloads to run on internet of things (IoT) edge devices via standard containers.
587 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Sander van de Velde | MVP 34,536 Reputation points MVP
    2025-01-16T13:44:59.37+00:00

    Hello @Athira Gopinath(UST,IN) ,

    welcome to this moderated Azure community forum.

    Being able to determine if a device is connected or not is a valid question.

    The IoT Hub provides device lifecycle events like connect and disconnect that you can route to some storage or stream.

    Be aware this is not a live message, the IoT Hub will provide it per 1 or a few minutes.

    You can also check the metrics collector of Azure IoT Edge. This provides information about how old the last batch of data is.

    Personally, I always add this custom heartbeat module which sends a message once every x seconds/minutes and provides a counter and a local date time. This way, I know how many times the module is restarted (probably indicting the shutdown of an edge device) and that local time can be compared with the iot hub enqueue time as an indication of connectivity delays.


    If the response helped, do "Accept Answer". If it doesn't work, please let us know the progress. All community members with similar issues will benefit by doing so. Your contribution is highly appreciated.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.