Ported code using httpWebRequest runs out of sockets


#1

I have quickly ported some old code written wayback in the .NET 2.0 timeframe that we use for stress testing a webserver over to .NET core. It basically spawns ~30 threads then hammers the webserver with requests. The issue I am having is that after about 30k requests the system runs out of ports and so cannot spawn any new requests (all the sockets are sitting in TIME_WAIT).

This issue was solved in .NET by setting the connection limit to 100 in the httpWebRequest ServicePoint, but this is not an option for core yet AFAICT. Is there any other way to get around this issue which doesn’t involve rewriting all the code?


#2

Probably a bit too late by now, but take a look at this
https://aspnetmonsters.com/2016/08/2016-08-27-httpclientwrong/

Issue caused by unnecessary disposing and instantiation of the HttpRequest object.


.NET Foundation Website | Blog | Projects | Code of Conduct