FTPWebRequest上传文件只会上传两个文件!
您好,我正在使用 WebRequest 的异步成员将文件上传到 IIS ftp 服务器。
我可以成功上传两个文件。然而,第三个文件上的 BeginGetResponse 永远不会调用我的回调例程!
欢迎任何想法吗?
谢谢,
约翰
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一些想法:
A few ideas:
感谢您的回复。我发现我的问题出在 ServicePoint.Connection.Limit 上,
我将此值增加到 4 并开始使用同步方法。我的 FTP 东西现在可以根据我的需要上传文件。
然而,尽管我可以验证我的文件是否完好无损地到达服务器,但流上的 Close() 方法大多数时候会抛出一个 Web 异常,抱怨连接已关闭。
我尝试过 KeepAlive,但只减少了大约 10%(非常粗糙)的传输异常。
我忽略了这些错误,因为我能够确认发送的字节数==文件总字节数,但这不是绅士风度。
我不太确定如何解决这个问题;我花了几天时间在谷歌上搜索,发现有人有类似的问题,但没有真正的答案。
目前我必须继续我的项目的其余部分,因为时间很短,如果您对如何防止底层连接关闭有任何想法(我猜这是控制通道丢失),我将不胜感激见解。
约翰.
Thanks for your response. I discovered that my issue was with ServicePoint.Connection.Limit
I increased this value to 4 and started using the Synchronous methods. My FTP stuff now uploads files as I require.
However though I can verify that my files reach the server intact The Close() method on the stream most of the time throws a web exception complaining that the connection was closed.
I've tried KeepAlive but only reduced the exceptions for about 10% (very rough) of the transfers.
I ignore the the errors as I am able to confirm that the bytes sent == the file total bytes but it is not gentlemanly.
I'm not really sure how to get round this; I spent days googling and found folk with similar issues but no real answers.
For the time being I have to continue with the rest of my project as time is short, If you have any ideas as to how to prevent the underlying connection from closing (I am guessing it's the control channel that drops) I'd appreciate your insights.
John.