ServicePointManager.DefaultConnectionLimit返回Int32.MaxValue [英] ServicePointManager.DefaultConnectionLimit returning 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中似乎将其设置为 Based on @Wimmel's link it seems in ASP.Net that it is set to 我们可以通过在 We can see this by looking inside the 有一个称为 There is a method called 这篇关于ServicePointManager.DefaultConnectionLimit返回Int32.MaxValue的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
推荐答案
Int32.MaxValue
作为HTTP运行时的一部分.Int32.MaxValue
as part of the HTTP Runtime.System.Web
程序集内部进行查看在HttpRuntime
类中.System.Web
assembly at the HttpRuntime
class.SetAutoConfigLimits
的方法将其设置为Int32.MaxValue
.
以下是相关摘录: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;
}