522 questions
5
votes
3
answers
148
views
.NET IHttpClientFactory + Microsoft Resilience retry: same HttpRequestMessage resent, delegating handler not re-running?
I have an HttpClient built with IHttpClientFactory and Microsoft.Extensions.Http.Resilience retry on 401. Pipeline:
Primary: HttpClientHandler (AllowAutoRedirect = false)
Delegating: ....
2
votes
1
answer
204
views
Aspire with a .NET 9 Blazor App: increasing Polly retry for HttpClientFactory while using a Http Message handler
I'm trying to increase my retry duration from the standard 10 seconds in my Blazor application, but the resilience handler doesn't seem to be working. I've tried both of the setups below but my Http ...
1
vote
1
answer
337
views
Blazor Server HttpRequest Timeout maximum is fix 30 seconds
I have a Blazor Server C# application in .NET 9 and I use a service to handle remote API calls. I would like to set timeout for requests globally like this:
var timeoutSec = builder.Configuration....
1
vote
1
answer
65
views
Preventing existing polly policy from being invoked for certain results
I have a predefined IAsyncPolicy<HttpResponseMessage> policy coming from an external assembly.
I want to apply this policy to a Http Client, BUT I want to exclude one of the cases this policy ...
1
vote
1
answer
124
views
C# Polly, 1st SqlException retry after 10 seconds then other all retries after 5 seconds until total 3 minutes
I am implementing Polly to retry SqlConnection errors.
This is the logic I need to implement:
1st SqlException - retry after 10 seconds
Total retrying time is 3 minutes
After 1st retry, all other ...
1
vote
1
answer
164
views
How can I add a Polly retry policy to AspNetCore.HealthChecks.Uris
How can I add a Polly retry policy to the AspNetCore.HealthChecks.Uris health check?
This health check is part of this repo:
https://github.com/Xabaril/AspNetCore.Diagnostics.HealthChecks
I see that I ...
1
vote
0
answers
472
views
Getting NU3018 error while doing dotnet restore on .NET 8 project
After upgrading my .NET 6 project to .NET 8, I am getting below errors on my windows build server while doing dotnet restore.
I do not get these errors on my Windows 10 development machine:
error ...
1
vote
1
answer
1k
views
How to configure the Rate Limiter of the StandardResilienceHandler
I'm writing an application that connects to another HTTP service. I want to rate-limit my outgoing requests to that external service.
Ideally, I want to use the standard resilience handler as ...
1
vote
1
answer
271
views
Identifying which Polly circuit breaker tripped in the OnOpened callback
I have several named HttpClients in my C# application. I am binding Polly policies (namely the circuit breaker) to each of them.
I need to capture which HttpClient tripped the circuit in the OnOpened ...
2
votes
1
answer
198
views
Retry strategy with exponential timeout
I use Polly to retry HTTP Requests. The following code works fine:
IAsyncPolicy<HttpResponseMessage> waitTimeout = Policy.TimeoutAsync<HttpResponseMessage>(TimeSpan.FromSeconds(5));
// ...
-1
votes
1
answer
111
views
IhttpClientFactory with DelegatingHandler create custom class
I am using IhttpClientFactory to call rest service. Injecting it in the class and using it.
public HttpClientLib(IHttpClientFactory clientFactory)
{
}
And using to call.
I have also created few ...
1
vote
1
answer
794
views
How to institute logging from Poly ResiliencePipeline for success after failure
In C# I'm using Polly Version=8.4.1 and a reusable retry ResiliencePipeline via ResiliencePipelineBuilder.
return new ResiliencePipelineBuilder()
.AddRetry(new RetryStrategyOptions
...
1
vote
1
answer
1k
views
The stream was already consumed. It cannot be read again error using Polly to retry requests C# .NET 6
I read this 'Stream was already consumed' error using Polly to retry requests in ASP.NET Core but cannot see where to clone the http request message.
So in my code, I register httpclient like:
...
-1
votes
1
answer
72
views
Polly Circuit-breaker propogates 500 error but not 5xx+ in http calls
HttpConsentCircuitBreakerPolicy = HttpPolicyExtensions
.HandleTransientHttpError()
.Or<TimeoutRejectedException>()
.CircuitBreakerAsync(3,TimeSpan.FromSeconds(30), OnBreak, OnReset);
...
2
votes
1
answer
2k
views
Using .NET8, on a "HttpIOException: The response ended prematurely", how can I add retries with exponential backoff?
developing a .Net8 application and currently having a need to perform http request retries when the connection ended prematurely (see ResponseEnded here)...
I wonder if I can use resilience mechanism ...
0
votes
1
answer
314
views
Why AddResilienceHandler in the statup code
I am using AddHttpClient and AddResilienceHandler to create and configure HttpClient in HostBuilder that will inject the httpclient in my other projects to handle specific http requests to different ...
4
votes
1
answer
3k
views
Migration from Polly to Microsoft.Extensions.Http.Resilience - Extend ShouldHandle
I want to migrate from Polly to the Microsoft.Extensions.Http.Resilience AddStandardResilienceHandler. My shortened Polly code is the following:
services.AddHttpClient<MyService>()
....
1
vote
1
answer
235
views
Polly Timeout Policy test doesn't work as expected
I am testing a Polly TimeOut policy
public static IAsyncPolicy<HttpResponseMessage> GetTimeoutPolicy(int timeoutSeconds)
{
return Policy.TimeoutAsync<HttpResponseMessage>(
...
0
votes
1
answer
39
views
Retry sending blank parameters for HTTP Post Request
When our retry code executes, it does a http post request passing in a parameter body.
The parameter body has data in it during debugging.
However, the http request content is blank, thus sending the ...
1
vote
0
answers
285
views
Polly v8 retry with Azure Service Bus and 3rd party API
I'd like to kindly ask for help with implementing retry strategy using Polly v8 in combination with Azure Service Bus and 3rd party API.
Setup
Messages are received from an ASB subscription. The ...
1
vote
1
answer
66
views
Increase error counter in CircuitBreaker later from values in the body of the response
We have a set of connectors with external providers using REST APIs. We use HttpClient and Polly to make resilient queries to the endpoints.
One of the providers is actually an intermediary between ...
-1
votes
1
answer
599
views
Does Polly Retry on errors like "connection was terminated abnormally" or "A connection with server could not be established" etc
I am using HTTPClient with WinHttpHanlder (for http/2) and my Polly retry policy looks something like this
var waitAndRetry = Policy
.HandleResult<HttpResponseMessage>(r => ...
1
vote
1
answer
1k
views
Polly v8 - Retrying specific status codes using the PredicateBuilder
I am using Polly v8 and .NET framework 4.7.2 to retry on specific status responses only. However, when trying to restrict the retry to only these statuses the code will no longer invoke the retry ...
3
votes
1
answer
2k
views
Polly final action after max retry
The C# project that I'm working on uses Polly (v8.3) for resiliency. The code looks very much similar to the sample found in the Github documentation :
ResiliencePipeline pipeline = new ...
1
vote
1
answer
301
views
How can I return 408 Request timeout to Polly so that it can apply retry policy?
I have the following client app
services
.AddHttpClient<IOrderService, OrderService>(c =>
{
c.BaseAddress = new Uri(Configuration["ApiSettings:xxx"]);
})
....