Data coming Iot hub stopped after VM restart only for a certain device

Helix Sense 0 Reputation points
2025-10-02T06:29:43.2966667+00:00

After I restarted the VM, data from one particular device stopped coming into the VM. I allowed the necessary ports and checked for possible throttling as well.

Could you please help me debug the iothub and VM interface to check the issue.

Azure IoT Hub
Azure IoT Hub
An Azure service that enables bidirectional communication between internet of things (IoT) devices and applications.
{count} votes

2 answers

Sort by: Most helpful
  1. Alex Burlachenko 18,390 Reputation points Volunteer Moderator
    2025-10-02T06:58:43.5033333+00:00

    Helix hi,

    this points directly to a problem with that specific device's connection, not the iot hub or vm's general configuration.

    since the vm restart is the event that triggered this, the issue is likely on the device side. the restart might have coincided with that one device's sas token expiring, a network glitch on its end, or the device itself entering a failed state.

    check the iot hub's built in metrics. go to your iot hub in the azure portal and look at the 'monitoring' section. check the 'routing delivery' metric and filter it by the specific device id that is failing. this will show you if the messages are even reaching the iot hub. if they are not, the problem is between the device and the cloud.

    next, use the azure iot hub device explorer or the az cli to check the device's twin and connection status. you can run this command.

    az iot hub device-identity show --device-id your_device_id --hub-name your_iothub_name

    look at the output to see if the device is enabled and its connection state. also, check the device's twin for any reported properties that might indicate an error.

    the most powerful tool is the resource logs for the iot hub. enable diagnostic settings on your iot hub to send logs to a log analytics workspace. then, you can run a kusto query to look for connection events and errors specifically for that device id. look for entries in the connections table.

    if the logs show the device is connecting and disconnecting, it could be a bad sas token. the device might need to regenerate its credentials.

    use iot hub metrics and diagnostics logs to trace the journey of the messages from that specific device. the logs will tell you if the problem is connection, authentication, or the device simply not sending data.

    regards,

    Alex

    and "yes" if you would follow me at Q&A - personaly thx.
    P.S. If my answer help to you, please Accept my answer
    

    https://ctrlaltdel.blog/

    0 comments No comments

  2. Jerald Felix 7,990 Reputation points
    2025-10-02T06:59:37.0133333+00:00

    Hi Helix Sense,

    Thanks for your question about the IoT device that stopped sending data after the VM restart. Here's a concise troubleshooting guide to debug the issue quickly:

    Quick Debugging Steps

    Check Device Status: In Azure Portal > IoT Hub > Devices, verify the device is Enabled and check its connection state. If it shows "disconnected" with an old timestamp, it hasn't reconnected since the restart.

    Duplicate Connection Issue: The most common cause is error 409002 LinkCreationConflict—IoT Hub thinks the old connection is still active. Wait 5-10 minutes for it to timeout, or manually disconnect/reconnect the device in the portal.

    Monitor in Real-Time: Run az iot hub monitor-events --hub-name <YourHub> --device-id <DeviceID> to see if messages are arriving. Check IoT Hub Logs for connection errors like 404104 DeviceConnectionClosedRemotely or 401002 Unauthorized.

    Verify Credentials: If using SAS tokens, confirm they haven't expired—regenerate the device key in the portal and update your VM's config.

    Network and Ports: Ensure port 8883 (MQTT) or 5671 (AMQP) is open on the VM firewall. Test with telnet <YourHub>.azure-devices.net 8883.

    Restart Device Client: On the VM, restart the specific application/service handling that device's IoT Hub connection—sometimes handlers don't auto-recover post-reboot.

    If these don't resolve it, collect device-side logs (enable SDK verbose logging) and check for application crashes or network timeouts.

    Best Regards,

    Jerald Felix

    0 comments No comments

Your answer

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