Azure / iot-edge-v1

Azure IoT Edge
http://azure.github.io/iot-edge/
Other
524 stars 258 forks source link

[v2] Edge device shown as disconnected but can send D2C messsages and receive Edge deployment #471

Closed LazarusX closed 6 years ago

LazarusX commented 6 years ago

I have my laptop simulate an Edge device, and follow the tutorial to create Edge deployment. My Edge device can successfully send D2C messages, and receive new deployments from the cloud. But by looking at the device twin, it is last updated about 7 hours ago, and thus listed as disconnected on Azure Portal, as the below screenshot shows: image

How can I troubleshoot and get my device twin to show the correct information?

grtn316 commented 6 years ago

It's my understanding that they are moving to module twins. So you need to look at the status of your deployed modules vs the general device hosting the modules.

damonbarry commented 6 years ago

What @grtn316 said is true for devices running the IoT Edge runtime: it communicates with IoT Hub as a module on the device (edgedevice/$edgeAgent), not as the device. Modules have identity and a twin just like devices, although modules are scoped to a device while devices are scoped to the hub.

See Azure/azure-iot-sdk-csharp#324

LazarusX commented 6 years ago

Below screenshot shows the module twins for $edgeAgent (left) and filterModule (right) respectively: image

Still, filterModule can successfully send D2C messages, and shown as "connected", but the $edgeAgent is shown as "disconnected".

In addition, there is a warning on the portal saying:

"Warning: Your device is disconnected from this IoT Hub. The information displayed below is not up to date. You can go to the device twin to see the last update time. If you have not set up your IoT Edge device, please follow IoT Edge QuickStart instructions. If you have already set up your device, please check device connectivity.".

Does this mean that just because the Edge module can send D2C dose not mean the Edge device or the Edge modules are connected? How can I get them connected again?

By the way, this happens after I woke my laptop from sleep which ran the Edge runtime before sleep. Could this be the cause?

damonbarry commented 6 years ago

We'll need to investigate this more; we're hearing some similar reports through other channels too.

Each module manages its own connection ($edgeAgent connects to IoT Hub, $edgeHub connects to IoT Hub and receives connections from other devices/modules, the simulated temp sensor connects to $edgeHub...) so you may have run into a situation where the sensor module was able to maintain its connection but the Edge Agent was not. It may have been due to the laptop sleep, but it's hard to say for certain.

The fact that your Edge Agent module lost its connection probably explains why the portal warns that your device is disconnected when it (kind of) isn't.

I suspect this is a bug in Edge Agent, but we need to investigate. We'll let you know if we need specific information from you.

LazarusX commented 6 years ago

Thanks Damon for the update.

I think my $edgeAgent should be actually connected, because when this error happened $edgeAgent could still receive and apply new module deployment from the cloud.

damonbarry commented 6 years ago

OK, let me summarize to make sure I understand what you're saying:

Does this sound accurate?

LazarusX commented 6 years ago

Almost correct, but filterModule is the module to send data to IoT Hub.

All modules ($edgeHub, $edgeAgent, tempSensor, filterModule) seem to function well, but are shown asDisconnected except filterModule.

stephenctw commented 6 years ago

Hi, I think I had a similar issue. I have a Modbus module(source of data) running over 24 hours and seems still be able to report D2C messages to IoT Hub(verified with Device Explorer). However, the edge device is reported disconnected on the Azure Portal and setting a module twin update doesn't work. Another thing I noticed is that there are around 900 messages being cleared from the queue each time edgeHub reestablish connection with Modbus module. I am attaching full logs for your reference.

Thanks.

edgehub.txt edgeAgent.txt dockerPS.txt dockerImages.txt

VitorX commented 6 years ago

same issue. The status of edge device is disconnected but the D2C message received successfully on IoT Hub. Edge Device Twin:

"deviceId": "EdgeDevice01", "etag": "AAAAAAAAAAE=", "deviceEtag": "MzQ4NTc1MzA4", "status": "enabled", "statusUpdateTime": "0001-01-01T00:00:00", "connectionState": "Disconnected", "lastActivityTime": "2018-07-16T06:51:38.0643715",

krokoko commented 6 years ago

Did you check the credentials you provided (registry password and sharedAccessKey for your modules) in your deployment manifest.json ? I had the same issue because of a typo error in the password.

aribeironovaes commented 6 years ago

Closing the issue due to lack of activity and also because it's on v1 repo. Please, if this issue still repro, can you move to gateway v2 repo? Here is the link: https://github.com/Azure/iotedge