The underlying connection was closed: An unexpected error occurred on a receive

不想你离开。 提交于 2019-12-04 22:56:32

Just want to strengthen ScottE's diagnosis, and be more specific. Timeout is most likely the issue.

Either .Net implementation of FtpWebRequest is erroneous or the MSDN document has a typo, the default value of FtpWebRequest.Timeout is not -1 (Infinite). It is 100000 (100 seconds).

In addition there is another timeout issue. A few tests have shown that responseStream always has a timeout value of 300000 (300 seconds). I do not know how this value is assigned. Anyways, this value needs to be modified to accommodate large files.

In summary, the solution is to set FtpWebRequest.Timeout and Stream.Timeout to a sufficiently large value.

Here's a good thread of things to try:

http://social.msdn.microsoft.com/Forums/en/ncl/thread/47634ec2-4d40-4d3f-b075-8cc92bfa2b24

Increasing the timeout is probably a good idea in the least.

This could be a symptom of an issue with the settings of your Windows Firewall. Disabling the "Application Layer Gateway Service" in the "services" interface fixed it for me.

This thread has a lot of information:

http://forum.parallels.com/pda/index.php/t-57966.html

Pradhan Salian

Try setting:

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