Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use RateLimiter with DependencyInjection #29

Open
bichuga opened this issue May 21, 2021 · 1 comment
Open

Cannot use RateLimiter with DependencyInjection #29

bichuga opened this issue May 21, 2021 · 1 comment

Comments

@bichuga
Copy link

bichuga commented May 21, 2021

See https://stackoverflow.com/questions/67577658/how-can-i-use-ratelimiters-httpclient-delegatinghandler-with-dependency-injecti

Issue:

[2021-05-17T21:58:00.116Z] Microsoft.Extensions.Http: The 'InnerHandler' property must be null. 'DelegatingHandler' instances provided to 'HttpMessageHandlerBuilder' must not be reused or cached.
[2021-05-17T21:58:00.117Z] Handler: 'ComposableAsync.DispatcherDelegatingHandler'.
[2021-05-17T21:58:00.122Z] An unhandled host error has occurred.
@jeffward01
Copy link

This can be fixed and is explained here: https://stackoverflow.com/questions/67577658/how-can-i-use-ratelimiters-httpclient-delegatinghandler-with-dependency-injecti

This line needs to be removed: https://github.com/David-Desmaisons/ComposableAsync/blob/e47a20178ff5a6e8a5bab5034dc6413720484bc2/ComposableAsync.Core/DelegatingHandler/DispatcherDelegatingHandler.cs#L21

ASP.NET Core should set that, not an external library. ASP.Net core handles that code, it expects to see null (so that it can set it via DI, but sees that it is not null (hence the error).

If we remove that line, the issue should be fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants