API Frequency Limit Issue: Overriding SendAsync in HttpClient Inherited Class Fails #114557
Unanswered
zms9110750
asked this question in
Q&A
Replies: 1 comment
-
The If you want to modify behavior of all calls, you can create a custom var httpClient = new HttpClient(new MyHandler(new SocketsHttpHandler()));
sealed class MyHandler(HttpMessageHandler inner) : DelegatingHandler(inner)
{
protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
{
await Task.Delay(5000, cancellationToken);
return await base.SendAsync(request, cancellationToken);
}
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
The API I need to access has a frequency limit. Therefore, I created a class that inherits from
HttpClient
and overridden theSendAsync
method. However, I still encountered an "access too fast" error when making calls.After checking the source code, I found that some methods call
base.SendAsync
. As a result, my override doesn't work. Is this by design?Beta Was this translation helpful? Give feedback.
All reactions