ServicePointManager.DefaultConnectionLimit返回Int32.MaxValue [英] ServicePointManager.DefaultConnectionLimit returning Int32.MaxValue

查看:126
本文介绍了ServicePointManager.DefaultConnectionLimit返回Int32.MaxValue的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

出于诊断目的,我正在记录ServicePointManager.DefaultConnectionLimit.但是奇怪的是,它似乎正在返回Int32.MaxValue(即2147483647).

For diagnostics purposes I am logging ServicePointManager.DefaultConnectionLimit. However oddly enough it seems to be returning Int32.MaxValue (i.e 2147483647).

这似乎与

ServicePoint对象允许的最大并发连接数.默认值为2.

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

对于上下文,我在运行于4.6.1的ASP.Net 4应用程序中获得了此值

For context, I am getting this value in an ASP.Net 4 application running on 4.6.1

推荐答案

基于@Wimmel的链接,在ASP.Net中似乎将其设置为Int32.MaxValue作为HTTP运行时的一部分.

Based on @Wimmel's link it seems in ASP.Net that it is set to Int32.MaxValue as part of the HTTP Runtime.

我们可以通过System.Web程序集内部进行查看在HttpRuntime中.

We can see this by looking inside the System.Web assembly at the HttpRuntime class.

有一个称为SetAutoConfigLimits的方法将其设置为Int32.MaxValue. 以下是相关摘录:

There is a method called SetAutoConfigLimits which sets it to Int32.MaxValue. Here is the relevant excerpt:

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;
}

这篇关于ServicePointManager.DefaultConnectionLimit返回Int32.MaxValue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆