Ocelot icon indicating copy to clipboard operation
Ocelot copied to clipboard

no QosHandler found in DI container

Open AugustCai opened this issue 6 years ago • 6 comments

Expected Behavior

Because gateway requests will be timed out in more than 100 seconds, i want to set the timeout time so that requests do not report errors.

Actual Behavior

ReRoute Ocelot.Values.UpstreamPathTemplate specifies use QoS but no QosHandler found in DI container. Will use not use a QosHandler, please check your setup!

Steps to Reproduce the Problem

  1. Install Ocelot.Provider.Polly
  2. to Startup#ConfigureServices the following: services.AddOcelot().AddPolly();
  3. Add a section into ocelot.json "QoSOptions": { "TimeoutValue": 300000 }
  4. Error occurred ReRoute Ocelot.Values.UpstreamPathTemplate specifies use QoS but no QosHandler found in DI container. Will use not use a QosHandler, please check your setup!

Specifications

  • Version: Ocelot v13.0.0, Ocelot.Provider.Polly v13.0.0
  • Platform: Windows 10 x64
  • Subsystem:

AugustCai avatar Jan 29 '19 03:01 AugustCai

If you want to just do timeouts, you can do this without having to do your own Ocelot fork/build or add Polly.

Copy and paste the HttpClientBuilder and HttpClientHttpRequester classes from the Github branch you are using into your project and rename the classes (MyHttpClientBuilder and MyHttpClientHttpRequester, for example).

In HttpClientHttpRequester change this line to create your custom HttpClientBuilder: var builder = new MyHttpClientBuilder(_factory, _cacheHandlers, _logger);

In your custom HttpClientBuilder, change the timeout to what you need: _defaultTimeout = TimeSpan.FromSeconds(600);

In startup.cs, add this AFTER the call to 'AddOcelot': services.RemoveAll<IHttpRequester>();

Then, somewhere after that, add: services.TryAddSingleton<IHttpRequester, MyHttpClientHttpRequester>();

eoware avatar Feb 11 '20 20:02 eoware

@AugustCai I didn't get your user scenario!

Could you upgrade your version to v22 and confirm that the bug still exists please?


Because gateway requests will be timed out in more than 100 seconds, i want to set the timeout time so that requests do not report errors.

But you can do that with

"QoSOptions": {
  "TimeoutValue": 5000
}

raman-m avatar Jan 14 '24 09:01 raman-m

@ggnaegi I didn't get author's user case! The author said about this line of code: https://github.com/ThreeMammals/Ocelot/blob/bb795876c493af958f1d58c852ea56e94263906d/src/Ocelot/Requester/DelegatingHandlerHandlerFactory.cs#L74 Wrong DI setup by author?

raman-m avatar Jan 14 '24 09:01 raman-m

@raman-m I would say so, we have reworked that part lately. Maybe it was a bug in version 13, maybe the user had to reference polly in his project?

ggnaegi avatar Jan 14 '24 22:01 ggnaegi

@ggnaegi commented on Jan 14

Yes, we have to validate this bug: the author provided Steps to Repro. But we have to perform validation for .NET 6+ and the latest v22 only (develop version too)

raman-m avatar Jan 15 '24 10:01 raman-m

@raman-m Ok, maybe @ks1990cn would be willing to perform the validation for us?

ggnaegi avatar Jan 15 '24 10:01 ggnaegi

@AugustCai Any default timeout issues will be addressed by #2073

raman-m avatar Jun 15 '24 12:06 raman-m

Duplicate of #2073

raman-m avatar Jun 15 '24 12:06 raman-m