This project is read-only.

Connection closed after the failed download

Oct 10, 2012 at 8:53 AM
Edited Oct 10, 2012 at 11:38 AM

I am trying to download the file from the ftp, I have provided the user interface. If the user closes the interface the should be closed.(and the download should be disconnected). Then after making a new connection, it is not working I am getting the error 'connection closed; ' 426. Please let me know if there is any work around.

Oct 10, 2012 at 1:33 PM

Sounds like the connection isn't being closed, make sure you call Disconnect() on the FtpClient object. If you are let me know which version you are running (default or System.Net.FtpClient_1 branches) and if at all possible provide a transaction log.

Oct 11, 2012 at 6:04 AM

Thanks for the reply. I have called the Disconnect() when closing the connection. I have used the October version system.Net.FTPclient 2012.10.02.01. still it not working

Oct 11, 2012 at 3:34 PM

I'm not sure I understand what's going on. If you call Disconnect() the connection is closed, if there is a transfer in progress the server will more than likely close the data connection and send a 4xx or 5xx reply which you need to catch. I don't see how it's possible that you're receiving a 4xx reply with an error message about the connection being closed unless the connection was still open when you called Connect() in which case the existing connection would be closed before a new connection was attempted. I can't do more to help solve this problem without the transaction log and a stack trace from when the 4xx reply was sent.

To get the transaction log, link the debug build of System.Net.FtpClient and add a trace listener per the examples in the CHM for the FtpClient class. In addition log the exception detail which should include a stack trace.