为了诊断目的,我正在记录ServicePointManager.DefaultConnectionLimit。然而,奇怪的是,它似乎正在返回Int32.MaxValue (即2147483647)。
这似乎与MSDN文档在这个问题上的观点相矛盾:
ServicePoint对象允许的最大并发连接数。默认值为2。
对于上下文,我在4.6.1上运行的ASP.Net 4应用程序中获得了这个值
发布于 2016-04-25 08:48:38
基于@Wimmel的链接,在ASP.Net中,它似乎被设置为Int32.MaxValue,作为HTTP的一部分。
我们可以通过班级看到这一点。
有一个名为SetAutoConfigLimits的方法将其设置为Int32.MaxValue。以下是有关节选:
private void SetAutoConfigLimits(ProcessModelSection pmConfig)
{
int workerThreads;
int completionPortThreads;
ThreadPool.GetMaxThreads(out workerThreads, out completionPortThreads);
if (pmConfig.DefaultMaxWorkerThreadsForAutoConfig != workerThreads || pmConfig.DefaultMaxIoThreadsForAutoConfig != completionPortThreads)
UnsafeNativeMethods.SetClrThreadPoolLimits(pmConfig.DefaultMaxWorkerThreadsForAutoConfig, pmConfig.DefaultMaxIoThreadsForAutoConfig, true);
ServicePointManager.DefaultConnectionLimit = int.MaxValue;
}https://stackoverflow.com/questions/36792608
复制相似问题