Silverlight ClientHttp WebRequest timeout

一个人想着一个人 提交于 2020-01-13 10:25:10

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/5475022/silverlight-clienthttp-webrequest-timeout

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!