How should the route-level global timeout be used in comparison with the QoS timeout in versions 23.3.0 - 24.0.1 ? #2305
-
Hello, we have been struggling with this issue for several weeks now. We need to disable retry, but keep timeout. We use QoSOptions for this and enable AddPolly(). On some endpoints, we need to have a timeout, but not repeat requests if the request fails due to a timeout or any other error. The problem is that we run a query, it works out the time allocated to it from the timeout QoSOptions and falls off, and then immediately runs two of the same queries in a row and falls off on them by timeout. We tried different ways: delegates, change configuration, disable polly. When we disable polly, the requests are not repeated, but the problem remains the same. We need a timeout, but without Polly, everything falls off after a minute and a half. The delegates don't help, it's like he doesn't see them. A timeout that does not belong to QoSOptions does not work. Please tell me what can be done in this case! Ocelot 24v |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 6 replies
-
Hello!
For the current versions 24.0.* the answer → Timeout strategy "QoSOptions": {
"TimeoutValue": 5000 // ms
} Don't specify other options at all! FYIA default timeout feature without QoS has been implemented in this commit: 7c583bf. However, it is still located in development branch, and it will be released in version 24.1.0 |
Beta Was this translation helpful? Give feedback.
-
That's correct, as the default 90-second timeout triggers the event as mentioned in our QoS Notes. To adjust the route global timeout duration, whether longer or shorter, you can use the C# recipe provided below. Currently, in versions 24.0.*, this is an undocumented feature (refer to MessageInvokerPool.cs#L35-L38 lines).
Using delegate handlers to solve the problem can be quite risky since the current timeout feature design relies on the TimeoutDelegatingHandler class. Please stop doing this!
Route timeout is not implemented at all in v24.0! There is global route timeout only, but it is undocumented! 😃
Until the release of the new v24.1 package, please use the following C# recipe to configure global route timeout aka Default timeout, in your Program.cs write this code: using Ocelot.DependencyInjection;
using Ocelot.Middleware;
using Ocelot.Requester;
// ...
var app = builder.Build();
// Because the IMessageInvokerPool service is a singleton, ...
var service = app.Services.GetService(typeof(IMessageInvokerPool)) as MessageInvokerPool;
// ...we will assign a global default timeout for all routes (600 seconds)
service.RequestTimeoutSeconds = 600; // (QoSOptions.TimeoutValue / 1000) seconds
await app.UseOcelot();
await app.RunAsync(); Notes
Hope this helps! |
Beta Was this translation helpful? Give feedback.
That's correct, as the default 90-second timeout triggers the event as mentioned in our QoS Notes. To adjust the route global timeout duration, whether longer or shorter, you can use the C# recipe provided below. Currently, in versions 24.0.*, this is an undocumented feature (refer to MessageInvokerPool.cs#L35-L38 lines).
Using delegate handlers to solve the problem can be quite risky since the current timeout feature design relies on the TimeoutDelegatingHandler class. Please stop doing this!