Silverlight ClientHttp Web请求超时

发布于 2024-10-27 09:22:49 字数 787 浏览 3 评论 0原文

我有一个 silverlight 4 应用程序,使用 ClientHttp 堆栈来创建一个提供二进制流服务的 WebRequest。然后我从这个流中读取并做一些事情。但是,我有以下问题:服务器缓冲了它发送下来的数据,因此发送过程就像发送-暂停-发送-暂停-发送...

有时服务器需要更长的暂停时间(大约20秒) ,此时连接似乎以某种方式中断。我在 Silverlight 中没有遇到任何异常,实际上对于代码来说,从 Web 响应流中读取数据似乎已完成(即没有更多数据)。然而,服务器实际上并没有发送所有数据(我可以从非 Silverlight 应用程序进行测试,该应用程序将在暂停后获取更多数据)。我认为这可能是一些超时问题(从我读到的内容来看,无法在 Silverlight 中明确设置),但奇怪的是我没有收到指示超时的异常。另外,停顿时间并没有那么长,我认为 20 秒是一个合理的时间。

我还查看了 TCP 流量,看起来在暂停后,Silverlight 向服务器发送了一条 FIN 消息。所以看起来它有点超时并决定中断连接,但它实际上并没有将超时报告为异常,也没有给我任何方法来避免它。

你知道到底发生了什么以及我该如何阻止它吗?

谢谢!

更新:发现问题。有一个注册表项控制系统范围的 Web 请求超时行为,某些应用程序将其设置为 10 秒(例如 Install Anywhere),然后“忘记”将其设置回来。关键是这样的: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ReceiveTimeout

我把它改回了一个更大的值,现在它工作正常了!哈。

I have a silverlight 4 application using the ClientHttp stack to make a WebRequest which serves a binary stream. I then read from this stream and do stuff. However, I have the following problem: the server buffers the data that it sends down, so that the send process is like send-pause-send-pause-send...

Sometimes the server takes a little longer pause (around 20 seconds), at which point the connection seems to somehow break. I don't get any exception in Silverlight, actually to the code it looks like the read from the web response stream finished ok (i.e. no more data). However, the server did not actually send all its data down (which I can test from a non-Silverlight application that will get more data after that pause). I'm thinking this might be some timeout issue (which from what I read around one can't set in Silverlight explicitly), but it's weird that I don't get an Exception indicating the timeout. Also, the pause is not that long, I would expect 20sec to be a reasonable time.

I've also looked at the TCP traffic and looks like after the pause, Silverlight sends a FIN message to the server. So it seems like it kind of times out and decides to break the connection, but it doesn't actually report the timeout as an Exception or give me any way to avoid it.

Any ideas what's actually going on and how could I prevent it?

Thanks!

UPDATE: Found the problem. There is a registry key that controls system-wide web request timeout behavior and some apps set it to 10 seconds (e.g. Install Anywhere) and "forget" to ever set it back. The key is this: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ReceiveTimeout

I changed it back to a greater value and now it works fine! Hth.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦初启 2024-11-03 09:22:49

仅引用OP但提供答案:

更新:发现问题。有一个注册表项控制系统范围的 Web 请求超时行为,某些应用程序将其设置为 10 秒(例如 Install Anywhere),然后“忘记”将其设置回来。关键是这样的:HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ReceiveTimeout

我把它改回了一个更大的值,现在它工作正常了!呵呵。

Merely quoting the OP but providing an answer:

UPDATE: Found the problem. There is a registry key that controls system-wide web request timeout behavior and some apps set it to 10 seconds (e.g. Install Anywhere) and "forget" to ever set it back. The key is this: HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ReceiveTimeout

I changed it back to a greater value and now it works fine! Hth.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文