Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
6.5k views
in .NET FTP by (120 points)
Hey everyone, i have downloaded the software and very happy with it, apart from the fact that it seems to fail downloading 1 file everytime, the other 131 files it downloads successfully.

Here is the code i am using to download the files.

Public Function DownloadFile(pTargetFile As String, pLocalFile As String) As Boolean

' set base
mFtp.RemoteHost = mRemoteHost

' connect
mFtp.Connect()

' login
mFtp.Login(mUsername, mPassword)

' set to passive
mFtp.ConnectMode = EnterpriseDT.Net.Ftp.FTPConnectMode.PASV

' set to binary
mFtp.TransferType = EnterpriseDT.Net.Ftp.FTPTransferType.BINARY

' set buffer size to 4mb
mFtp.TransferBufferSize = 4096

' set large timeout (thought this would help for large files?)
mFtp.ServerWakeupInterval = 60

' change to correct directory
mFtp.ChDir(mRemoteDirectory)

' download file
mFtp.Get(mLocalDirectory & "\" & pLocalFile, pTargetFile)

Return True

End Function

I have enabled logging and this is the bit that fails

DEBUG [FTPClient] 24 Nov 2008 10:55:28.343 : Found 67 listing lines
DEBUG [FTPFileFactory] 24 Nov 2008 10:55:28.343 : Parse() called using culture: Invariant Language (Invariant Country)
INFO [BSL.Library.Ftp.FtpClient] 24 Nov 2008 10:55:32.734 : Downloading file 'BACKUP.safe'
DEBUG [FTPControlSocket] 24 Nov 2008 10:55:32.765 : ---> PASV
DEBUG [FTPControlSocket] 24 Nov 2008 10:55:32.828 : 227 Entering Passive Mode (XX,XX,XX,XX,20,24).
DEBUG [FTPControlSocket] 24 Nov 2008 10:55:32.828 : Server supplied address=XX,XX,XX,XX
DEBUG [FTPControlSocket] 24 Nov 2008 10:55:32.828 : Server supplied port=5144
DEBUG [FTPControlSocket] 24 Nov 2008 10:55:32.828 : NewPassiveDataSocket(XX,XX,XX,XX,5144)
DEBUG [FTPControlSocket] 24 Nov 2008 10:55:32.875 : ---> RETR BACKUP.safe
DEBUG [FTPControlSocket] 24 Nov 2008 10:55:32.937 : 125 Data connection already open; Transfer starting.
INFO [FTPClient] 24 Nov 2008 10:56:32.937 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 10:56:32.937 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 10:57:32.937 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 10:57:32.937 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 10:58:32.937 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 10:58:32.937 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 10:59:32.937 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 10:59:32.937 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 11:00:32.937 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 11:00:32.937 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 11:01:32.937 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 11:01:32.937 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 11:02:32.937 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 11:02:32.937 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 11:03:32.968 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 11:03:32.968 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 11:04:32.968 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 11:04:32.968 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 11:05:32.968 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 11:05:32.968 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 11:06:33.015 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 11:06:33.015 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 11:07:33.140 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 11:07:33.140 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 11:08:33.140 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 11:08:33.140 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 11:09:33.140 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 11:09:33.140 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 11:10:33.140 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 11:10:33.140 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 11:11:33.156 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 11:11:33.156 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 11:12:33.250 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 11:12:33.250 : ---> NOOP
INFO [FTPClient] 24 Nov 2008 11:13:33.250 : Sending server wakeup message
DEBUG [FTPControlSocket] 24 Nov 2008 11:13:33.250 : ---> NOOP
ERROR [FTPClient] 24 Nov 2008 11:16:20.781 : 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.GetBinary(String localPath, String remoteFile)
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] 24 Nov 2008 11:16:21.265 : Setting socket timeout=500
DEBUG [FTPControlSocket] 24 Nov 2008 11:16:22.484 : Setting socket timeout=120000
ERROR [BSL.Library.Ftp.FtpClient] 24 Nov 2008 11:16:22.546 : Function DownloadFile(BACKUP.safe, BACKUP.safe) : 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.StreamReader.ReadBuffer()
at System.IO.StreamReader.ReadLine()
at EnterpriseDT.Net.Ftp.FTPControlSocket.ReadReply()
at EnterpriseDT.Net.Ftp.FTPClient.ValidateTransfer()
at EnterpriseDT.Net.Ftp.FTPClient.ValidateTransferOnError()
at EnterpriseDT.Net.Ftp.FTPClient.Get(String localPath, String remoteFile)
at BSL.Library.Ftp.FtpClient.DownloadFile(String pTargetFile, String pLocalFile) in C:\FtpClient.vb:line 238
CAUSED BY:
System.Net.S

3 Answers

0 votes
by (162k points)
The problem is that the server is timing out your connection because the transfer is taking a long time. The NOOPs being sent aren't working to keep the connection alive.

The only solution is for the timeout to be increased on the server side.
0 votes
by (140 points)
Hello,

I encountered the same exception when trying to download a relatively small file. The underlying root cause was a bug in my code which put both Linux-style (/) and Windows-style (\) path separators in the local directory string: "C:\temp/data/". This caused edtFTPnet to throw an exception, which was then caught and in turn caused the misleading timeout exception to be thrown.

I too am very happy with the product! I just wanted to share this in the hopes that it might save someone else a few minutes of debugging.
0 votes
by (162k points)
thanks - useful to know

Categories

...