C# HTTP 请求最大连接数 [英] C# HTTP request Max connections

查看:89
本文介绍了C# HTTP 请求最大连接数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有多个网络服务器 (15),每个服务器都有多个 URL(30).我编写了一个 Windows 桌面应用程序,它可以访问每个服务器和每个 url 组合.(使用 httpWebRequest.Proxy 来做到这一点).它通常一次只用于 2 个服务器.所以总共有 60 个请求.

第一个问题是 2 个连接限制,所以我将其添加到 Form Load 中:ServicePointManager.DefaultConnectionLimit = 500

这有帮助,但后来我似乎遇到了另一个限制.

在我们为这些网站推出代码后,他们可能需要一段时间才能做出回应.初始化过程需要 30-40 秒!不过那是另一个故事了.

但似乎有 Windows XP 连接限制.如果我打开 IE 并尝试访问一个站点,而我正在运行我的应用程序来检查站点,则 IE 需要很长时间才能返回页面.一旦应用开始收到请求并关闭它们,IE 也会收到它的响应.

此外,我们正在调用的页面还为我们提供了调用其他 WebService 调用所需时间的计时.这些时间有时很慢,但有时很快.我在我发出的每个 HTTP 请求上都有一个计时器,一旦我发出请求,它就会启动计时器.有时页面指定的响应时间和 HTTP 请求的计时器之间的差异非常大,比如 40 秒.

所以我认为正在发生的是请求正在排队并且它的计时器正在运行,但尚未发送到页面.

有谁知道我需要更改什么才能增加 Windows XP 中的总连接限制?我已经阅读了有关注册表更改或 tcpip.sys 编辑的内容,但希望 Stackoverflow 中睿智而聪明的小组给出明确的答案.

谢谢,我希望这是有道理的.

解决方案

您能否尝试将其添加到您的 app.config 中:

<预><代码><配置><system.net><连接管理><add address="*" maxconnection="65535"/></连接管理></system.net></配置>

We have a number of webservers(15) and for each server have a number of URLs(30). I have written a Windows Desktop app that goes out and hits each server and each url combo. (using the httpWebRequest.Proxy to do this). It's usually just for 2 servers at a time. So a total of 60 requests.

The first problem was the 2 connection limit, so I added this to the Form Load: ServicePointManager.DefaultConnectionLimit = 500

That helped, but then I seem to run into another limit.

After we roll code out for these sites, they can take a while to respond. The init process takes like 30-40 seconds! That's another story though.

But there seems to be a Windows XP connection limit. If I have IE open and am trying to access a site, while I a running my app to check sites, the IE takes a long time until it gets a page back. Once the app starts getting requests back and closes them, then IE gets it's response back as well.

Also the page we are calling gives us back timings of how long it took to call other WebService calls. These times are sometimes slow, but sometimes quite fast. I have a timer on each HTTP Request I make that starts the timer once I make the request. Sometime the difference between the page's specified response time and the HTTP request's timer is quite large, like 40 seconds.

So what I think is happening is the request is being queued up and it's timer is running, but has not yet been sent to the page.

Does anyone know what I would need to change to increase the total connection limit in Windows XP? I have read about registry changes or tcpip.sys editing, but would like a definitive answer from the wise and intelligent group at Stackoverflow.

Thanks and I hope this makes sense.

解决方案

Could you try addding this to your app.config:

<configuration> 
  <system.net> 
    <connectionManagement>
      <add address="*" maxconnection="65535" />
    </connectionManagement>
  </system.net> 
</configuration>

这篇关于C# HTTP 请求最大连接数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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