I am attempting to stress test my service. To do that I call
await client.PostAsync(url, content);
Normal calls that go through there work just fine. But when I hit it hard, the client call above (to post to the service) starts to fail.
At first it starts to give this error:
System.Threading.Tasks.TaskCanceledException: A task was canceled.
It also will give this error:
System.Net.Sockets.SocketException (10055): An operation on a socket could not be performed because the system lacked sufficient buffer space or because a queue was full.
Then after short time, the errors change to:
System.Net.Sockets.SocketException (10048): Only one usage of each socket address (protocol/network address/port) is normally permitted.
My code is part of a NuGet package that will run in normal .Net Framework applications (WCF, WPF, ASP.NET etc) and the newer ASP.Net Core 3.1.
Because of that I don't really have easy access to the .Net Core DI framework. (I don't really want to make it for the normal .Net Framework and I don't want to make another instance of DI for the ASP.NET Core 3.1 apps.)
So I create my HttpClient
like this.
private static readonly HttpClient client = new HttpClient{Timeout = TimeSpan.FromSeconds(25)};
Is there some other configuration I need to setup to all my HttpClient
to handle a lot of very fast calls (approx 250,000 as fast as it can go)?
Or is there some way to detect that the HttpClient
is saturated and wait until it is in a better state?