Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Net.ServicePointManager.DefaultConnectionLimit == 24 --> BUG?

When checking the System.Net.ServicePointManager.DefaultConnectionLimit in .Net 4 in my debugger, I see really high numbers. I see 24 on one machine and see 48 on another machine.

This is even the case for a newly created ASP.NET MVC 3 project without any configuration changes done to it. Is this a bug? The documentation clearly states that the default is 2:

The maximum number of concurrent connections allowed by a ServicePoint object. The default value is 2.

From http://msdn.microsoft.com/en-us/library/system.net.servicepointmanager.defaultconnectionlimit(v=VS.100).aspx

The DefaultNonPersistentConnectionLimit and DefaultPersistentConnectionLimit fields are more realistic 4 and 2, respectively, but the DefaultConnectionLimit number seems out of range.

like image 297
Johnny Oshika Avatar asked Mar 30 '11 15:03

Johnny Oshika


People also ask

What is ServicePointManager DefaultConnectionLimit?

The DefaultConnectionLimit property sets the default maximum number of concurrent connections that the ServicePointManager object assigns to the ConnectionLimit property when creating ServicePoint objects.

Does HttpClient use ServicePointManager?

HttpClient connections management in . NET Framework 4.5 and +, the default constructor of HttpClient uses the HttpClientHandler class, which leverages the HttpWebRequest class to send HTTP requests. Therefore, we can use the good old ServicePoint and ServicePointManager classes to manage opened connections.


1 Answers

It's not a bug. It's propably 12 per CPU.

The value comes from <connectionManagement> in your Web.config or Machine.config. If neither of files contains element it's probably configured by autoConfig=True setting at <processModel> element.

like image 151
Jakub Šturc Avatar answered Sep 19 '22 18:09

Jakub Šturc