我知道这是一个模糊的问题,尤其是因为我不提供任何code,但我开发的.Net 2.0应用程序,我们有一个WebRequest的哪些职位数据,内部内置API。
I know this is a vague question, especially since I am not providing any code, but I am developing a .Net 2.0 application, and we have a WebRequest which posts data to an internally built API.
但奇怪的事情发生在我们的3号(总是3日)未有在请求的GetRequestStream()方法的后续请求。第一和第二次其所谓的,一切都很好。在第三次,它挂了一下,最终超时。
The strange thing happens on our 3rd (and always the 3rd) subsequent request which fails at the GetRequestStream() method of the request. The first and second time its called, all is fine. On the 3rd time, it hangs for a bit and eventually times out.
该API是由家中的其他应用程序调用,所以我们知道它不是一个服务器端的,或网络问题。我们试图在几台机器 - 所有这些有同样的问题。有没有人收到了这个问题,或有没有人对如何调试(因为响应对象没有任何一代产量,或者至少是没什么用处)任何sugestions。
The API is being called by other applications in house, so we know its not a server-side, or networking issue. We've tried on several machines - all of which have the same problem. Has anyone ever had this problem before, or does anyone have any sugestions about how to debug (since the response object doesn't yeild anything, or at least nothing useful).
推荐答案此,如果你不处理提供WebResponse通常发生。有适用于连接的数量从客户端在同一台机器的限制,默认情况下它的两项。连接可重复使用(或关闭),如果您关闭WebResponse的。 using语句是你的朋友在这里:
This usually happens if you're not disposing the WebResponse. There's a limit applied to the number of connections from a client to the same machine, and by default it's two. The connections can be reused (or closed) if you close the WebResponse. The using statement is your friend here:
WebRequest request = [...]; // Do stuff with the request stream here (and dispose it) using (WebResponse response = request.GetResponse()) { // Stuff with the response }更多推荐
HttpWebRequests在随后的调用失败
发布评论