views:

354

answers:

2

Hi I'm using the aynchronous members of the WebRequest to upload files to an IIS ftp server.

I can upload two files with success. However BeginGetResponse on the third file never calls my call back routine!

Any Ideas welcome?

thanks,

john

A: 

A few ideas:

  • make the requests synchronously and see if the problem goes away. if not, then start looking closely at that third file (is it HUUUUUUUUUGE?)
  • make sure you're explicitly calling FtpWebRequest.EndGetResponse() in your callback handler, and then calling Close() on the response. Otherwise you'll risk leaving connections open and perhaps bumping up against client, server, or proxy connection limits.
  • if you're already doing those things, install a network sniffer like Network Monitor 3.3 and see what's actually happennig on the wire. You'll be able to see any errors there.
  • if you see errors, track them down. if you never actually see the third request go over the wire, look at client connection limits as the culprit. If you see the third request go over the wire, but no response, look at a server issue like throttling N requests from same client within M seconds-- and try putting in a delay after each request to see if you can avoid this.
Justin Grant
A: 

Hi Justin,

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.

John