Azure / azure-iot-sdk-csharp

A C# SDK for connecting devices to Microsoft Azure IoT services
Other
457 stars 493 forks source link

[Bug Report] When try to fetch reported properties after updating the reported property it will return previous version of reported property not the latest one. #3437

Open malavvvakharia opened 4 months ago

malavvvakharia commented 4 months ago

Steps:

  1. Try to update any key via ModuleClient.UpdateReportedPropertiesAsync method.
  2. Get the latest twin via ModuleClient.GetTwinAsync method.
  3. When you get the twin after updating then it contains the older version of reported properties.

Code:

public async Task UpdateReportedProperties(TwinCollection twinCollection)
    {
        _logger.Debug("Invoking UpdateReportedProperties");
      _logger.Debug("Module twin before updating : {ModuleTwin}", ModuleTwin);
        await _moduleClient.UpdateReportedPropertiesAsync(twinCollection);
          ModuleTwin = await _moduleClient!.GetTwinAsync();
       _logger.Debug("Module twin after updating : {ModuleTwin}", ModuleTwin);
   }
abhipsaMisra commented 4 months ago

Is this a leaf module (connected directly to IoT Hub) or an edge module (connected to IoT Hub via IoT Edge)? (Edge modules don't always apply the patch immediately.)

malavvvakharia commented 4 months ago

So, you mean that it will not work if it's an edge module? So, can I put a delay before fetching it like Task.Delay(10000) or any other solution do you have?