This project is read-only.

FtpClient.FtpCommandException: Data connection closed, file transfer aborted

Oct 25, 2012 at 3:58 PM

It doesn't consistently happen but it seems to happen often that I get one of these messages.  This makes it where I can't fully process the file.  Is there a timeout or max size that I need to set?

Oct 25, 2012 at 4:02 PM

I'm not really sure what you're asking for. It looks like the data connection was closed premature or was never connected and the server gave an error response. You can catch the exception and handle it accordingly however to really understand what's going on I need some more information. Was this an upload or a download? How far along was the transfer when this happened and was the transfer hung or?

Oct 25, 2012 at 4:02 PM

Also, which version of System.Net.FtpClient are you using?

Oct 25, 2012 at 4:30 PM

Sorry for the abstract post.  I am not sure on what all is happening.  I can't recreate it on my desktop, it only seems to happen on the server I am deploying my web service to.  I know it pretty far into the download and processing operation.  It doesn't appear to be an issue with connecting and opening the file.  That is why I think it is the timeout issue.  I did find the DataChannelReadTimeout property on the FtpClient and upped into 10 minutes, so hopefully this will work.  But I am not sure if there is something else I need to set, so the server doesn't close the connection.

I was hoping there was more insight into this error.  Is it always caused by the server closing the connection?  What is the default value of the DataChannelReadTimeout?

As for the version, looking at the dll, it doesn't appear have a tracking version number, unless I did end up getting  The dll is from 9/10/2012 in the morning, if that helps narrow it down.

Oct 25, 2012 at 7:34 PM

The default is 15 seconds. Another thing to consider is that the webserver may possibly time out a process that's been running too long. I don't know a lot about ASP.NET and how it interacts with IIS but it's not uncommon to see a max execution time in regards to server side applications.

Oct 25, 2012 at 7:39 PM

Yes , it is always caused by an abnormal disconnection of the data channel, i.e., the data connection was closed before the server finished sending all of the data. It's less common on an upload because closing the stream signifies EOF to the server or client. When downloading, the server knows exactly how much data is being sent so it can detect that the connection was terminated before it sent all of the data and give a 4xx or 5xx reply.

Oct 25, 2012 at 7:41 PM

Looks like you're running the System.Net.FtpClient_1 branch which is the old code base. If you don't have the latest revision of the code it might be worthwhile to get it. There was some bugs in the last binary builds that were fixed and committed to the repository but never got released as a new build.

Oct 25, 2012 at 10:23 PM

Thank you.  I think 15 seconds could be the reason mine was stopping.  I am reading from the server into a stream and processing that stream as I read it in.  This is to avoid saving it to a directory somewhere and rereading it from disk.  On larger files or slower server times 15 seconds could easily be hit.  I will watch my processes and make sure the issue doesn't continue.