HttpWebRequests在随后的调用失败

编程入门 行业动态 更新时间:2024-10-23 15:33:02
本文介绍了HttpWebRequests在随后的调用失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我知道这是一个模糊的问题,尤其是因为我不提供任何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在随后的调用失败

本文发布于:2023-07-15 10:25:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1110649.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:在随后   HttpWebRequests

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!