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

[Bug Report] DeviceClient.SendEventAsync takes over one minute after update from 1.42.0 to 1.42.2 #3426

Closed
fabianmeyer opened this issue Feb 6, 2024 · 7 comments
Labels
bug Something isn't working. .NET 8

Comments

@fabianmeyer
Copy link

fabianmeyer commented Feb 6, 2024

Context

  • OS, version, SKU and CPU architecture used: Ubuntu 23.10 64-bit
  • Application's .NET Target Framework : net8
  • Device: Laptop
  • SDK version used: Microsoft.Azure.Devices.Client 1.42.2

Description of the issue

After updating from Microsoft.Azure.Devices.Client 1.42.0 to 1.42.2, calls to SendEventAsync take over one minute in comparison to ~700ms before.

Code sample exhibiting the issue

var deviceClient = DeviceClient.CreateFromConnectionString($"HostName={cloudGatewayHostname};DeviceId={deviceId};SharedAccessKey={sharedAccessKey}", TransportType.Mqtt);
var sw = Stopwatch.StartNew();
_logger.LogInformation("Sending event as device {DeviceId} to IoT Hub", deviceId);
await deviceClient.SendEventAsync(message, cancellationToken);
_logger.LogInformation("Sent event as device {DeviceId} to IoT Hub ({Duration}ms)", deviceId, sw.Elapsed.TotalMilliseconds);

Console log of the issue

1.42.0
Sent event as device 00000001-4505-009d-5741-ec8495e2bc03 to IoT Hub (755.3321ms)
1.42.2
Sent event as device 00000001-4505-009d-5741-ec8495e2bc03 to IoT Hub (71925.7335ms)

@fabianmeyer fabianmeyer added the bug Something isn't working. label Feb 6, 2024
@TheDon79
Copy link

TheDon79 commented Feb 7, 2024

It seems to be, that I am running into the same/a very similar problem. When using Version 1.42.2 deviceClient.SendEventAsync runs into a Timeout and throws an IotHubCommunicationException with Transient network error occurred, please retry. Returning to Version 1.4.0 resolves this issue.

@timtay-microsoft
Copy link
Member

timtay-microsoft commented Feb 7, 2024

Do you see this same behavior on .NET 7 as well? And do you see it when using AMQPS as well?

@fabianmeyer
Copy link
Author

Besides NET8, I only have the NET6 SDK installed, for which the issue does not occur (same duration for 1.42.0 and 1.42.2).
The issue also does not occur when using AMQP with 1.42.2 on NET8.

@TheDon79
Copy link

  • deviceClient.SendEventAsync works in .NET7 with 1.42.2
  • it works in .NET8 with AMQP but not with MQTT (or MQTT_TCP_ONLY)
  • it works in .NET8 with 1.42.0

It seems that the client stops to communicate with the IoT Hub after the Server Hello Done.
grafik

@timtay-microsoft
Copy link
Member

We suspect this is related to a .NET 8 bug in DotNetty (the MQTT library we use). The fix for this bug in DotNetty has been merged and we are working on putting out a new DotNetty release. Once we have released DotNetty, we'll put out a release of this SDK with the new DotNetty version which should resolve this issue.

@jenscski
Copy link

Looks like DotNetty is out with new version, I have added direct refereces to DotNetty and it looks like it's working now

<PackageReference Include="DotNetty.Codecs.Mqtt" Version="0.7.6" />
<PackageReference Include="DotNetty.Handlers" Version="0.7.6" />

@timtay-microsoft
Copy link
Member

This behavior should be fixed in the new release:
https://github.com/Azure/azure-iot-sdk-csharp/releases/tag/2024-03-28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. .NET 8
Projects
None yet
Development

No branches or pull requests

4 participants