-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
WaitAndRetryAsync causes app hang when retrying a "503 - Service unavailable" response #790
Comments
@reisenberger any thoughts ? |
@marcpaulv We are facing this issue today. Did you get any update on this ? |
hi @gethari, no update on this from this repo, unfortunately. I did log another issue on https://github.com/dotnet/extensions/issues/3385. I didn't get any replies there either, but I found a workaround by talking to miself :)) |
As a cross-referencing since the issue was reported in the other repository as well, I created a self-contained reproducing solution for this occurrence under https://github.com/Dragonsangel/PollyConnectionsRemainOpen |
As dotnet/aspnetcore/issues/28384 suggests, the issue might have been resolved in .NET 6 RC2. Meanwhile for older versions, the advised solution is to explicitly dispose the HttpPolicyExtensions.HandleTransientHttpError().WaitAndRetryAsync(
new[] { TimeSpan.FromSeconds(1), TimeSpan.FromSeconds(2), TimeSpan.FromSeconds(4) },
(response, _, _, _) => response?.Result.Dispose()
) |
This issue is stale because it has been open for 60 days with no activity. It will be automatically closed in 14 days if no further updates are made. |
We are still facing this issue and should not be closed. |
Hey @Dragonsangel , this problem is fixed in Polly V8 as it automatically disposes discarded results. See:
I am not sure if this will be backported to V7. |
Summary:
When the Application Pool of an IIS hosted website stops for whatever reason (in my case i stopped it manually), IIS returns a 503 - Service unavailable status code and adds a Connection: close response header.
When retrying such a request with the
WaitAndRetryAsync
policy, the first 2 retries are returning the same status (503) but the third retry is causing the application to stop responding.Steps to reproduce
Expected behavior:
The application should start receiving 200 OK responses.
Actual behaviour:
The application hangs after the first 2 retries of the first 503 Service unavailable response.
Note that if the
WaitAndRetryAsync
policy addition is commented out, the application behaves as expected (without the retries of course).Code to reproduce the problem:
Observations
If you retry the request only once, the behavior is as expected.
The problem seems to appear when you retry more than once with the same
HttpClient
instance.The text was updated successfully, but these errors were encountered: