ServicePointManager.DefaultConnectionLimit returning Int32.MaxValue

前端 未结 1 1275
长发绾君心
长发绾君心 2021-01-14 07:19

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

This

相关标签:
1条回答
  • 2021-01-14 07:30

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

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

    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;
    }
    
    0 讨论(0)
提交回复
热议问题