How to configure Polly v8 with the Ocelot 23.2.2? #2083
-
In Polly v8, we have observed that the circuit breaker functionality is not working as expected. We have experienced issues where the circuit breaker does not trip or reset correctly, leading to inconsistent fault handling. Conversely, in Polly v7, the circuit breaker also exhibits problems, failing to operate smoothly in certain scenarios. ExampleSuppose you have configured an Ocelot route with a circuit breaker policy to trip after three consecutive HTTP request failures: {
"Routes": [
{
"DownstreamPathTemplate": "/api/StudentIdentity/Verify ",
"DownstreamScheme": "https",
"DownstreamHostAndPorts": [
{
"Host": "localhost", "Port": 5001
}
],
"UpstreamPathTemplate": " api/student/Verify ",
"UpstreamHttpMethod": [ "Get" ],
"QoSOptions": {
"ExceptionsAllowedBeforeBreaking": 3,
"DurationOfBreak": 10000,
"TimeoutValue": 5000
}
}
]
} Configuration in Program.cs for V7: services.AddLogging(logging =>
{
logging.ClearProviders();
logging.AddConsole();
});
services.AddJwtAuthentication();
services.AddOcelot().AddPollyV7(); Configuration in program.cs using Polly V8: services.AddLogging(logging =>
{
logging.ClearProviders();
logging.AddConsole();
});
services.AddJwtAuthentication();
services.AddOcelot().AddPolly(); Expected BehaviourDuring runtime, the downstream service fails five consecutive times. The circuit breaker should trip and stop the request to be forwarded , and move to open state as per configured. Actual behaviorDuring runtime, the downstream service fails five consecutive times. Despite this, the circuit breaker does not trip and continues to forward requests, instead of moving to the open state after three failures as configured. Scenario 1When service response is delayed from the service configured in ocelot. Scenario 2When service is giving 503 error response . Scenario 3When Service is giving 404 error response. Can you please suggest, how to configure Polly v8 with the current Ocelot version 23.2.2? |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 8 replies
-
@anonimousspider, thank you for your question! Could you please provide your full name? It seems you're experiencing issues with the V7 provider. However, since the QoS package has been updated to the latest Polly version (V8 syntax), we advise using only Ocelot's |
Beta Was this translation helpful? Give feedback.
This comment was marked as spam.
This comment was marked as spam.
-
Hi Anonimous, I'm trying to reproduce your case. |
Beta Was this translation helpful? Give feedback.
This comment was marked as spam.
This comment was marked as spam.
-
For me, your sample seems to be correct. I don't unsderstand where is the issue |
Beta Was this translation helpful? Give feedback.
Official Polly documentation
Official Ocelot documentation
What's your full name?
What's your LinkedIn?