-
Notifications
You must be signed in to change notification settings - Fork 492
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
AMQP OpenAsync doesn't timeout after 1 min when network is offline #1203
Comments
It should be the same cause as |
I can repro this issue, and even saw a case where it took over 4 minutes to time out. I worry about fixing the behavior only because we've had a fair number of complaints for internal and external customers anytime the default behavior changes, even when it isn't an API surface change. However, I may have a reliable solution for you. I did find that if I included a cancellation token to the call to OpenAsync, from a var deviceClient = DeviceClient.CreateFromConnectionString(deviceConnectionString);
var sw = new Stopwatch();
sw.Start();
using var cts = new CancellationTokenSource(TimeSpan.FromSeconds(15)); // also tried 30 and 60 seconds
try
{
await deviceClient.OpenAsync(cts.Token).ConfigureAwait(false); //cts.Token
}
catch (Exception ex)
{
Console.WriteLine(ex.Message); // no host found
}
sw.Stop();
Console.WriteLine(sw.Elapsed); // just slightly over the desired timeout Will this work for you? @davilu is right, that a big part of the problem is in the AMQP library we use - not to say this code couldn't have been written to actually work. Still, with what seems to be a viable workaround to me, perhaps we are best to let the existing behavior remain. |
@ancaantochi, @davilu, thank you for your contribution to our open-sourced project! Please help us improve by filling out this 2-minute customer satisfaction survey |
Description of the issue:
Create ModuleClient with AMQP transport settings and call OpenAsync when the network is offline. Would expect the call to timeout in 1 minute which I can see in the logs is used for timeout, but it times out after 2 minutes, sometimes longer.
Code sample exhibiting the issue:
Console log of the issue:
The text was updated successfully, but these errors were encountered: