增加ServicePointManager.DefaultConnectionLimit的缺点 [英] Disadvantage of increasing ServicePointManager.DefaultConnectionLimit

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

问题描述

我正在多线程环境中调用Web服务.我的许多调用由于操作超时或错误请求而失败,但是如果我以线性方式执行操作,则所有调用都不会失败,这意味着调用具有多个线程的Web服务时会出现问题.经过大量分析,我发现并发连接的限制导致了这些异常,因此我通过添加以下代码对其进行了修复.

I am calling a webservice in multi threaded environment. Lot of my calls fail due to operation time out or bad request but none of the calls fail if I do it in linear fashion which means there is problem with invoking webservice with multiple threads. After lot of analysis, I found out that there is limit of concurrent connection which is causing these exception so I fixed it by adding below code.

 ServicePointManager.DefaultConnectionLimit = 2 * _ThreadCount;

我不知道是增加此限制的可能缺点.默认情况下,连接限制为2.如果有人知道任何不利之处,请告诉我.

What I dont know is the possible disadvantage of increasing this limit. By default, Connection limit is 2. If anyone knows any disadvantages, please do let me know.

推荐答案

更改DefaultConnectionLimit属性对现有的无效 ServicePoint对象;它仅影响以下对象的ServicePoint对象: 更改后初始化.如果此属性的值没有 是直接设置还是通过配置设置,默认值为 到常量DefaultPersistentConnectionLimit.

Changing the DefaultConnectionLimit property has no effect on existing ServicePoint objects; it affects only ServicePoint objects that are initialized after the change. If the value of this property has not been set either directly or through configuration, the value defaults to the constant DefaultPersistentConnectionLimit.

注意

对DefaultConnectionLimit属性的任何更改都会影响两个HTTP 1.0和HTTP 1.1连接.无法单独更改HTTP 1.0和HTTP 1.1协议的连接限制.当用于 服务器环境(ASP.NET)DefaultConnectionLimit默认为 更高的连接数,即10.

Any changes to the DefaultConnectionLimit property affect both HTTP 1.0 and HTTP 1.1 connections. It is not possible to separately alter the connection limit for HTTP 1.0 and HTTP 1.1 protocols. When used in the server environment (ASP.NET) DefaultConnectionLimit defaults to higher number of connections, which is 10.

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

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