Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
7.5k views
in .NET FTP by (1.2k points)
I am constantly getting this error:

ERROR [FTPClient] 30 Jun 2008 18:42:37.875 : Caught exception : System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
at EnterpriseDT.Net.Ftp.FTPClient.ReadChunk(Stream input, Byte[] chunk, Int32 chunksize)
at EnterpriseDT.Net.Ftp.FTPClient.a(String A_0, String A_1)
CAUSED BY:
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
DEBUG [FTPControlSocket] 30 Jun 2008 18:42:37.890 : Setting socket timeout=500
DEBUG [FTPControlSocket] 30 Jun 2008 18:42:38.921 : Setting socket timeout=120000
DEBUG [AsyncProcessor] 30 Jun 2008 18:42:38.921 : Stopping FTP task processor.
DEBUG [AsyncProcessor] 30 Jun 2008 18:42:38.921 : FTP task processor stopped.
A first chance exception of type 'System.IO.IOException' occurred in edtFTPnetPRO.dll
A first chance exception of type 'EnterpriseDT.Net.Ftp.FTPException' occurred in edtFTPnetPRO.dll

This happens directly after a downloaded file completes. Sometimes this causes my files to disappear. I also have redundancy built into my code:

            int retryCount = 0;
            int maxRetries = 10;
            bool succeeded = false;
            dConnection.DeleteOnFailure = false;

            do
            {
                try
                {
                    dConnection.Connect();
                    if (retryCount > 0)
                    {
                            dConnection.ResumeTransfer();
                    }
                    dConnection.DownloadFile(Path.Combine(localPath, fileName), remoteFile[partNumber]);
                    succeeded = true;
                }
                catch (Exception)
                {
                    retryCount++;
                    // should log exception here
                }
                finally
                {
                    try
                    {
                        dConnection.Close();
                    }
                    catch (Exception)
                    {
                        // should log exception here
                    }
                }
            } while (!succeeded && retryCount <= maxRetries);

9 Answers

0 votes
by (51.6k points)
Hi Aaron

It's hard to see what's happening from what you've posted.

A few questions:
  • Are you sure every byte of the file has been downloaded when this happens?
  • Does it happen every time or intermittently? If it happens intermittently, is there a pattern to when it happens? For example, does it only happens after a lot of files have been transferred?
  • If you are using multiple connections, does it happen if you reduce it to use only one connection?
  • What is your time-out? If the time-out is very short then it might help if you increase it.

- Hans (EnterpriseDT)[/list]
0 votes
by (1.2k points)
We have multiple (10) connections downloading simultaneously. We see all the files in the folder that they should be in. The log only shows some of the transfered files. For example, this shows that seven of the 10 have transferred, but in the destination folder we see all 10.

DEBUG [FTPClient] 30 Jun 2008 23:07:38.953 : Transferred 22326412 bytes from remote host
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 30 Jun 2008 23:07:40.453 : KeepAlive - testing connection
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 30 Jun 2008 23:07:40.453 : Testing connection
DEBUG [FTPControlSocket] 30 Jun 2008 23:07:40.453 : ---> PWD
DEBUG [FTPControlSocket] 30 Jun 2008 23:07:40.640 : 257 "/EWU/McNeese" is current directory.
DEBUG [FTPClient] 30 Jun 2008 23:07:43.359 : Transferred 22326412 bytes from remote host
DEBUG [FTPClient] 30 Jun 2008 23:07:54.078 : Transferred 22326412 bytes from remote host
DEBUG [FTPClient] 30 Jun 2008 23:07:56.625 : Transferred 22326412 bytes from remote host
DEBUG [FTPClient] 30 Jun 2008 23:07:59.687 : Transferred 22326412 bytes from remote host
DEBUG [FTPClient] 30 Jun 2008 23:08:00.343 : Transferred 22326412 bytes from remote host
DEBUG [FTPClient] 30 Jun 2008 23:08:01.875 : Transferred 22326406 bytes from remote host


Our timeout is set to 120000, after it reaches the timeout, it throws this error for the three connections that are missing:

ERROR [FTPClient] 30 Jun 2008 23:09:19.046 : Caught exception : System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
System.IO.IOException: Unable to read data from the transport connection: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.IO.BufferedStream.Read(Byte[] array, Int32 offset, Int32 count)
at EnterpriseDT.Net.Ftp.FTPClient.ReadChunk(Stream input, Byte[] chunk, Int32 chunksize)
at EnterpriseDT.Net.Ftp.FTPClient.a(String A_0, String A_1)
CAUSED BY:
System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
DEBUG [FTPControlSocket] 30 Jun 2008 23:09:19.078 : Setting socket timeout=500
DEBUG [FTPControlSocket] 30 Jun 2008 23:09:20.109 : Setting socket timeout=120000
A first chance exception of type 'System.IO.IOException' occurred in edtFTPnetPRO.dll


Once this error is thrown, for each exception thrown one of the files in the destination folder is deleted. We discovered that only 98% of the bytes for these files are being downloaded. We are thinking that the connections are being closed before all the bytes are being downloaded, but we don't know why this is happening or how to fix it. On the server side we see all the files and they have all the
0 votes
by (1.2k points)
I forgot to mention that it only appears to happen with files that are large. We know that it works with files under 200 MB.
0 votes
by (162k points)
If it only happens with large files, the connection is possibly being timed out by the server and terminated. Try increasing the server timeout. Some servers time out connections even though files are being transferred, if there is no activity on the control channel.
0 votes
by (1.2k points)
Well, I can check it, but the main connection never times out during the transfer and sometimes we transfer files that take 1.5 hours and no time out ever occurs. Also the timeout should only occur if there is no activity at all after 10 minutes. It is really annoying to have 98-99% of a file download and then it throw this error. What other possible solutions could there be?
0 votes
by (162k points)
Given that FTP is inherently not 100% reliable, your code above that does a resume should be sufficient - if a file is 98% transferred and there is an error, that code should simply resume the transfer and do the last 2% in the next iteration of the loop. Is that not happening?
0 votes
by (1.2k points)
I'm testing it now, but we haven't been successful with it so far. Can you give me some code that does it with asynchronous methods?
0 votes
by (51.6k points)
I have replied to this message by e-mail.

- Hans (EnterpriseDT)
0 votes
by (500 points)
Well, I can check it, but the main connection never times out during the transfer and sometimes we transfer files that take 1.5 hours and no time out ever occurs. Also the timeout should only occur if there is no activity at all after 10 minutes. It is really annoying to have 98-99% of a file download and then it throw this error. What other possible solutions could there be?


"Also the timeout should only occur if there is no activity at all after 10 minutes." -> could you please explain why 10 minutes? I have tried various timeout values and if ftp server is disconnected, I get timeout exception only after 10 minutes (even though I set to 2 minutes or 4 minutes) - I like to see the exception earlier than 10 minutes.

Is the 10 minutes some magic number?

Thanks much !

Categories

...