question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] After a certain number of timeouts ARM ends up in a bad state where all future calls also timeout

See original GitHub issue

Library name and version

Azure.ResourceManager 1.7.0

Describe the bug

After a certain number of timeouts exception resource manager ends up in a bad state where all subsequent calls will time out even if the far end is available. The application needs to be restarted.

This seems to only happen when multiple ArmClients are created. If we pass in HttpClients to each one and dispose of them when we are done the problem disappears. This seems to have something to do with all Azure SDK clients, by default, sharing a single HttpClient instance.

Expected behavior

Subsequent calls work and are not impacted by previous timeouts.

Actual behavior

All calls time out until the application is restarted.

Here is the exception we get:

Exception: ClientSecretCredential authentication failed: Request to the endpoint timed out. at Azure.Identity.CredentialDiagnosticScope.FailWrapAndThrow(Exception ex, String additionalMessage) at Azure.Identity.ClientSecretCredential.GetToken(TokenRequestContext requestContext, CancellationToken cancellationToken) at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.AccessTokenCache.GetHeaderValueFromCredentialAsync(TokenRequestContext context, Boolean async, CancellationToken cancellationToken) at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.AccessTokenCache.GetHeaderValueAsync(HttpMessage message, TokenRequestContext context, Boolean async) at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.AccessTokenCache.GetHeaderValueAsync(HttpMessage message, TokenRequestContext context, Boolean async) at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.AuthorizeRequest(HttpMessage message) at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory1 pipeline, Boolean async) at Azure.Core.Pipeline.BearerTokenAuthenticationPolicy.Process(HttpMessage message, ReadOnlyMemory1 pipeline) at Azure.Core.Pipeline.HttpPipelinePolicy.ProcessNext(HttpMessage message, ReadOnlyMemory1 pipeline) at Azure.Core.Pipeline.RedirectPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory1 pipeline, Boolean async) at Azure.Core.Pipeline.RedirectPolicy.Process(HttpMessage message, ReadOnlyMemory1 pipeline) at Azure.Core.Pipeline.RetryPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory1 pipeline, Boolean async) at Azure.Core.Pipeline.RetryPolicy.ProcessAsync(HttpMessage message, ReadOnlyMemory1 pipeline, Boolean async) at Azure.Core.Pipeline.RetryPolicy.Process(HttpMessage message, ReadOnlyMemory1 pipeline) at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory1 pipeline) at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory1 pipeline) at Azure.Core.Pipeline.HttpPipelineSynchronousPolicy.Process(HttpMessage message, ReadOnlyMemory`1 pipeline) at Azure.Core.Pipeline.HttpPipeline.Send(HttpMessage message, CancellationToken cancellationToken) at Azure.ResourceManager.Compute.VirtualMachinesRestOperations.InstanceView(String subscriptionId, String resourceGroupName, String vmName, CancellationToken cancellationToken) at Azure.ResourceManager.Compute.VirtualMachineResource.InstanceView(CancellationToken cancellationToken)

Reproduction Steps

int count = 20;

ArmClient client = null;

while (true)
   {
      try
         {
            Console.WriteLine(count);

            if (count > 0)
            {
               count--;

               ArmClientOptions armClientOptions = new ArmClientOptions();

               if (count > 0)
               {
                  armClientOptions.Retry.NetworkTimeout = TimeSpan.FromMilliseconds(1);
               }

               client = new ArmClient(new DefaultAzureCredential(), string.Empty, armClientOptions);
            }

            var vm = client.GetVirtualMachineResource(new ResourceIdentifier(ResourceId));

            var view = vm.InstanceView();

            Thread.Sleep(TimeSpan.FromSeconds(3));

            }
            catch (Exception ex)
            {
               Console.WriteLine(ex.ToString());
            }
         }
   }

Environment

This was run on windows 10 using .net 6 and Visual Studio 17.1.1

Issue Analytics

  • State:closed
  • Created 2 months ago
  • Comments:32 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
jfleuryStatcancommented, Aug 11, 2023

It seems like using a singleton for ARMClient, ArmClientOptions and HttpClient solved our problems. At least we haven’t had any exceptions or lockups in the last three weeks.

0reactions
github-actions[bot]commented, Jul 28, 2023

Hi @jfleuryStatcan, we’re sending this friendly reminder because we haven’t heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don’t hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!

Read more comments on GitHub >

github_iconTop Results From Across the Web

[BUG] After a certain number of timeouts ARM ends up in ...
[BUG] After a certain number of timeouts ARM ends up in a bad state where all future calls also timeout #27437. Sign in...
Read more >
Bug? Forced Concede Due To Stack Timeout : r/MagicArena
What happens here is an issue with animations - game server obviously does not play them. If there are 200 triggers on stack...
Read more >
Franchise - AI bug; CPU in no huddle lets time run out before ...
Summarize your bug AI calls timeout incorrectly after the playclock runs down in no huddle, sometimes ending the game with the CPU losing...
Read more >
Anger Management Manual
In fact, effective anger management involves controlling the escalation of anger by learning assertiveness skills, changing negative and hostile thoughts or “ ...
Read more >
USTA Officiating: Scenarios and Interpretations
Do the players change ends after a 7-Point Tiebreak is played to decide a set? Yes. (Rule 10). 2. Service Order – If...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found