Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twin update is not triggered after a module reconnection #7148

Closed
MiraLak opened this issue Nov 9, 2023 · 6 comments
Closed

Twin update is not triggered after a module reconnection #7148

MiraLak opened this issue Nov 9, 2023 · 6 comments

Comments

@MiraLak
Copy link

MiraLak commented Nov 9, 2023

Expected Behavior

I update the twin properties in the cloud, the changes are instantly synchronized in the edge module.
The edge module is disconnected (no internet connection)
The twin properties are updated in the cloud
The edge module is reconnected (no twin changes locally while it was offline)
The twin changes are spread to the edge module and properties are updated in the edge.

Current Behavior

The edge module is disconnected (no internet connection)
The twin properties are updated in the cloud
The edge module is reconnected (no twin changes locally while it was offline)
The twin changes are never sent to the edge module after reconnection.

Steps to Reproduce

Provide a detailed set of steps to reproduce the bug.
1.Have a working IoT Edge device with one module container (connecting to EdgeHub) running
2. Update twin properties in the IOThub (in the azure portal) and see changes arrive to the Edge Device
3. Disconnect the Edge Device (cut internet connection of the device so it became offline but still running)
4. Update twin properties in the IOThub again in the cloud
5. Reconnect the Edge Device and check the twin properties if they get updated in the device

Context (Environment)

Device Information

  • Host OS: Linux
  • Architecture: amd64
  • Container OS: Linux containers

Runtime Versions

  • aziot-edged: 1.4.9
  • Edge Agent: 1.4.9
  • Edge Hub: 1.4.9
  • Moby: 23.0.7
@vadim-kovalyov
Copy link
Contributor

Hey @MiraLak, sorry to hear you have issues with twin refresh. Although it is hard to say without edge hub logs, and it is not clear what SDK your custom module uses, one possible explanation is that if edge is offline for extended period, the retry interval is 300 sec (5min). So, it means you might need to wait up to ~5min to make sure the edge hub reconnects.

Another possibility is that you don't handle disconnect/connect events. I'm not sure about what SDK you use, but it could be custom module responsibility to check for reconnection and re-request the twin.

So let us know what SDK you use and please provide the support bundle with debug logs, so maybe we can engage the SDK team on this.

@MiraLak
Copy link
Author

MiraLak commented Nov 17, 2023

Hey @vadim-kovalyov ,
Thank you for your answer. I've waited more than 5min (up to an hour) and nothing happened.
Which logs you would be interested in?
We are using Microsoft.Azure.Devices.Client version 1.42.0

@timtay-microsoft
Copy link
Member

timtay-microsoft commented Nov 22, 2023

From a conversation I had elsewhere with @vipeller :

Hi, this is the way it is supposed to work:

  • edgeHub maintains the last known state of desired properties
  • if there is a change in the desired properties, then iot hub sends a notification to edgeHub, which tracks this change in its own version, and also sends the delta between the previous version and the new version to the client
  • if edgeHub is offline, and it cannot receive notifications from IoTHub, and the connecting client asks for desired properties, then edgeHub will sends its own known state
  • Then later when edgeHub reconnects to IoTHub, it pulls the entire twin, it calculates the delta to its last known version and sends a notification to the client as it were sent by IotHub.

So in theory, the fact that edgeHub was offline for a while, it should not matter: with some delay, the client is expected to receive the changes, maybe multiple changes aggregated.

This is the part that doesn't seem to be working for the user here.

The SDK team has already engaged with the @MiraLak to get most of the details. So, to clear up some possible confusion, there are no connection issues between the module and Edgehub. @MiraLak is only seeing disconnects between Edgehub and IoT hub. So this part

Another possibility is that you don't handle disconnect/connect events. I'm not sure about what SDK you use, but it could be custom module responsibility to check for reconnection and re-request the twin.

isn't relevant in this case.

@MiraLak I believe the support bundle logs @vadim-kovalyov is looking for here are detailed here

@vadim-kovalyov
Copy link
Contributor

Hey @MiraLak sorry for delay, it was a holiday (Thanksgiving) week here in the US. Thanks @timtay-microsoft for clarifying, now I better understand what is the problem. As @timtay-microsoft mentioned, for me to troubleshoot further please try the following:

  • update the EdgeHub and EdgeAgent and, ideally, the runtime as well (aziot-edged) to the latest version (1.4.25+)
  • Please enable the debug logs by setting RuntimeLogLeve=debug for EdgeHub container, and try to repro the issue again.
  • Please note the time when you put device offline, when you modified the twin, and when you brought the device back online.
  • Please collect the support bundle and share it with us over the email thread we have.

Also, if you can send a simple minimal repro (a simple module with the code to handle twin updates) that would help a lot.

Copy link

This issue is being marked as stale because it has been open for 30 days with no activity.

@bishal41
Copy link
Contributor

@MiraLak based on the e-mail thread you are included on (Ref: case # 2402190050000566); I am closing this issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants