Questions tagged [polly]

Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. Polly targets .NET Standard 1.1 and .NET Standard 2.0.

Polly is a .NET resilience and transient-fault-handling library that allows developers to express policies such as Retry, Circuit Breaker, Timeout, Bulkhead Isolation, and Fallback in a fluent and thread-safe manner. Polly targets .NET Standard 1.1 and 2.0+. For further information read Polly's wiki.

454 questions
5
votes
1 answer

Polly HandleTransientHttpError not catching HttpRequestException

I've created a retry policy on my HttpClient in the Startup.ConfigureServices method. Note also that by default, asp.net core 2.1 logs 4 [Information] lines for each call made by the HttpClient which are shows in the logs at the end of my…
SeanOB
  • 752
  • 5
  • 24
5
votes
1 answer

How can I use Polly to retry x number of times based on response content and then return the response?

In my app I am using the Polly library to call an API. The API can return warnings and errors in the response. For some of these warnings I want to retry 2 times and the next time I would like to return the response to the caller. Can this be…
Vinyl Warmth
  • 2,226
  • 3
  • 25
  • 50
5
votes
1 answer

What is the best order to apply multiple Polly policies?

The order in which Polly policies are encapsulated change the final result. Which is the best order if I want to use the following policies? This is the best order I could think of: the retries should be submitted to the bulkhead limits, and the…
5
votes
3 answers

Using exponential backoff in Polly Library with httpclient

I just read about Polly library and I need to handle 3 retries when communicating from a desktop agent to a server. Currently I like the exponential backoff. However, I struggle to understand how to implement this in my code. This is what I have…
grozdeto
  • 1,201
  • 1
  • 13
  • 34
5
votes
2 answers

Polly -how do I log final error and continue?

I'm trying to set up Polly in .Net Core 3.1 (Azure Functions v3). I want to create a Policy in the Startup class which I can inject into functions. The behaviour that I'm looking for is: It should wait And retry 3 times - if the final try fails -…
PSXYU
  • 101
  • 2
  • 8
5
votes
1 answer

Polly retry with different url

I am trying to create a solution with polly where I request an other api. I have a list of URLs to multiple instances of the same service. I want that when the first request failes, an other should automaticly start with the next url from my…
csk
  • 73
  • 1
  • 7
5
votes
2 answers

Proper way to handle multiple services with polly circuit breaker

I have an application where we communicate with hundreds of HTTPs endpoints. The application is a proxy of sorts. When testing with polly, I've noticed that if one endpoint, say api.endpoint1.com fails, the calls to api.endpoint2.com and…
5
votes
1 answer

How to decide what exceptions are worth retrying when reading and writing to MongoDB (C# driver)?

By looking at this official documentation it seems that there are basically three types of errors thrown by the MongoDB C# driver: errors thrown when the driver is not able to properly select or connect to a Server to issue the query against. These…
Enrico Massone
  • 6,464
  • 1
  • 28
  • 56
5
votes
1 answer

Refresh Token using Polly with Typed Client

I have a Typed Client which i have configured in the services and i am using Polly to make retries for transient faults. Aim: I want to make use of Polly to implement refresh token, whenever there is a 401 response from the target site, i want Polly…
kartik rajan
  • 115
  • 1
  • 5
5
votes
1 answer

Can I combine Retry and Fallback Polly resilience policies?

I would like to perform a certain operation, and if it fails three times return null. Something like this in Polly would be perfect: var results = await Policy> .Handle() .RetryAsync>(3) …
Aidan
  • 4,783
  • 5
  • 34
  • 58
5
votes
3 answers

Receiving error 'The request message was already sent' when using Polly

I am currently using Polly to limit the number of requests I send. This is the policy I currently have: private AsyncPolicyWrap DefineAndRetrieveResiliencyStrategy() { HttpStatusCode[] retryCodes = { …
Ryan Falzon
  • 329
  • 4
  • 15
5
votes
1 answer

How to use policy wrap on RetryPolicy?

I have the following retry policy which uses Polly.Extensions.Http: var retryPolicy = Policy.Handle().OrTransientHttpError().WaitAndRetryAsync ( retryCount: maxRetryCount, …
Nimish David Mathew
  • 2,958
  • 6
  • 29
  • 45
5
votes
0 answers

Using Polly with TPL Dataflow

Data processing pipelines and transient fault handling seem to go hand in hand, so I'm interested in seeing if I can get 2 of the best libraries for these - TPL Dataflow and Polly, respectively - to play nicely together. As a starting point, I'd…
Todd Menier
  • 37,557
  • 17
  • 150
  • 173
4
votes
2 answers

Polly rate limiting too early

I'm trying to get my head around Polly rate-limit policy. public class RateLimiter { private readonly AsyncRateLimitPolicy _throttlingPolicy; private readonly Action _rateLimitedAction; public RateLimiter(int numberOfExecutions,…
Arthur Rey
  • 2,990
  • 3
  • 19
  • 42
4
votes
2 answers

RateLimiting - Incorrect limiting

I have a RabbitMQ Queue, filled with thousands of messages. I need my consumer to consume 1 message per second, so I have implemented a RateLimit policy using Polly. My configuration is as follows: public static IAsyncPolicy GetPolicy(int mps) { …
Katia S.
  • 197
  • 2
  • 13
1 2
3
30 31