Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
1.2k views
in .NET FTP by (560 points)

Hi All,

I just try to use download directory method. I have succeeded to download some directories indeed. However i am getting errors while downloading some directories.

The code is like that

SecureFTPConnection connection = new SecureFTPConnection();

connection.Protocol = FileTransferProtocol.FTPSExplicit;

connection.ServerAddress = this.host;
connection.ServerPort = this.port;
connection.UserName = this.username;
connection.Password = this.password;
connection.Timeout = 5000000;
connection.ServerValidation = SecureFTPServerValidationType.None;

SecureFTPConnection.LogLevel = EnterpriseDT.Util.Debug.LogLevel.All;
SecureFTPConnection.LogFile = @"\\tekdplf1\NetDeployment\Sources\Test\Log.txt";

connection.Connect();

connection.DownloadDirectory(localDirectory, remoteDirectory);

The Error Trace:

INFO [SSLFTPSocket] 20 Oca 2016 12:59:58.862 : Connecting to [FTP_IP_ADDRESS]:51157 with timeout 5000000 ms
DEBUG [ExFTPPassiveDataSocket] 20 Oca 2016 12:59:58.862 : Created passive data-socket: ProxyConnector=
DEBUG [SSLFTPPassiveDataSocket] 20 Oca 2016 12:59:58.862 : Created passive data-socket: Protocol=Ssl3, Tls1, Tls11, CompatibilityFlags=Standard, UseSSLClosure=True, WaitOnClose=True
ALL [SecureSocket] 20 Oca 2016 12:59:58.862 : SecureSocket timeout=5000000
ALL [SecureSocket] 20 Oca 2016 12:59:58.862 : SecureSocket timeout=5000000
DEBUG [FTPControlSocket] 20 Oca 2016 12:59:58.862 : ---> RETR System.Net.Http.dll
ALL [SocketController] 20 Oca 2016 12:59:58.877 : WaitUntilCompleted(1765, EndSend)
ALL [AsyncResult] 20 Oca 2016 12:59:58.877 : Notify setting completed: null 1765
ALL [AsyncResult] 20 Oca 2016 12:59:58.877 : Notify setting wait: 1765
ALL [AsyncResult] 20 Oca 2016 12:59:58.877 : WaitOne completed: 1765
WARN [SocketController] 20 Oca 2016 12:59:58.908 : OnReceive - (An existing connection was forcibly closed by the remote host) - closing
DEBUG [SocketController] 20 Oca 2016 12:59:58.910 : CloseConnection(e=An existing connection was forcibly closed by the remote host)
DEBUG [SocketController] 20 Oca 2016 12:59:58.910 : Closed socket
ALL [AsyncResult] 20 Oca 2016 12:59:58.911 : Notify setting completed: An existing connection was forcibly closed by the remote host 1765
ALL [AsyncResult] 20 Oca 2016 12:59:58.912 : Notify setting wait: 1765
ALL [SocketController] 20 Oca 2016 12:59:58.912 : Notified active send result 1765
DEBUG [TransferBuffer] 20 Oca 2016 12:59:58.914 : Close() called when open
DEBUG [SecureSocket] 20 Oca 2016 12:59:58.914 : OnHandshakeComplete(False,An existing connection was forcibly closed by the remote host)
WARN [SecureNetworkStream] 20 Oca 2016 12:59:58.962 : Socket.Send() failed: An error occurred while communicating with the remote host.
ERROR [FTPControlSocket] 20 Oca 2016 12:59:58.976 : Exception in SendCommand
ERROR [FTPControlSocket] 20 Oca 2016 12:59:58.976 : System.IO.IOException: An I/O exception occurred.
ERROR [FTPControlSocket] 20 Oca 2016 12:59:58.976 :    at TDXAJl3QrLwq936QWgG.Rg2rMV3j8dir2aCcrGs.Write(Byte[] , Int32 , Int32 )
ERROR [FTPControlSocket] 20 Oca 2016 12:59:58.976 :    at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
ERROR [FTPControlSocket] 20 Oca 2016 12:59:58.976 :    at System.IO.StreamWriter.Flush()
ERROR [FTPControlSocket] 20 Oca 2016 12:59:58.976 :    at EnterpriseDT.Net.Ftp.FTPControlSocket.rbgstCdlveS(String command)
ERROR [FTPControlSocket] 20 Oca 2016 12:59:58.976 :    at EnterpriseDT.Net.Ftp.FTPControlSocket.SendCommand(String command)
ERROR [FTPControlSocket] 20 Oca 2016 12:59:58.976 : CAUSED BY - EnterpriseDT.Mentalis.Security.SecurityException: An I/O exception occurred.
ERROR [FTPControlSocket] 20 Oca 2016 12:59:58.976 :    at EMbTMu3glxCCwTCq4tB.B7VOWR3rZM1FhGCgkmy.RgYsmw86ORT(IAsyncResult )
ERROR [FTPControlSocket] 20 Oca 2016 12:59:58.976 :    at EMbTMu3glxCCwTCq4tB.B7VOWR3rZM1FhGCgkmy.Send(Byte[] , Int32 , Int32 , SocketFlags )
ERROR [FTPControlSocket] 20 Oca 2016 12:59:58.976 :    at TDXAJl3QrLwq936QWgG.Rg2rMV3j8dir2aCcrGs.Write(Byte[] , Int32 , Int32 )
ERROR [FTPConnection] 20 Oca 2016 12:59:58.983 : Command error
ERROR [FTPConnection] 20 Oca 2016 12:59:58.983 : System.IO.IOException: An I/O exception occurred.
ERROR [FTPConnection] 20 Oca 2016 12:59:58.983 :    at TDXAJl3QrLwq936QWgG.Rg2rMV3j8dir2aCcrGs.Write(Byte[] , Int32 , Int32 )
ERROR [FTPConnection] 20 Oca 2016 12:59:58.983 :    at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
ERROR [FTPConnection] 20 Oca 2016 12:59:58.983 :    at System.IO.StreamWriter.Flush()
ERROR [FTPConnection] 20 Oca 2016 12:59:58.983 :    at EnterpriseDT.Net.Ftp.FTPControlSocket.rbgstCdlveS(String command)
ERROR [FTPConnection] 20 Oca 2016 12:59:58.983 :    at EnterpriseDT.Net.Ftp.FTPControlSocket.SendCommand(String command)
ERROR [FTPConnection] 20 Oca 2016 12:59:58.983 : CAUSED BY - EnterpriseDT.Mentalis.Security.SecurityException: An I/O exception occurred.
ERROR [FTPConnection] 20 Oca 2016 12:59:58.983 :    at EMbTMu3glxCCwTCq4tB.B7VOWR3rZM1FhGCgkmy.RgYsmw86ORT(IAsyncResult )
ERROR [FTPConnection] 20 Oca 2016 12:59:58.983 :    at EMbTMu3glxCCwTCq4tB.B7VOWR3rZM1FhGCgkmy.Send(Byte[] , Int32 , Int32 , SocketFlags )
ERROR [FTPConnection] 20 Oca 2016 12:59:58.983 :    at TDXAJl3QrLwq936QWgG.Rg2rMV3j8dir2aCcrGs.Write(Byte[] , Int32 , Int32 )
DEBUG [FTPConnection] 20 Oca 2016 12:59:58.990 : Closing connection (instance=0)

by (161k points)
FTP/FTPS uses a separate TCP connection for each data transfer upload, download, or directory listing).  TCP ports go into a TIME_WAIT state for a number of seconds after each connection, making it unusable for this period.  This means that it is possible to run out of TCP ports when multiple files are transferred in a short period of time. Please try using the MultiTransferXXX settings to slow down the transfers.
by (560 points)
I have tried with several combinations of them. But it still fails with the same error. Do you have any suggestions about the values of these parameters?

connection.MultiTransferCountBeforeSleep = 50;
connection.MultiTransferSleepEnabled = true;
connection.MultiTransferSleepTime = 30;

connection.MultiTransferCountBeforeSleep = 10;
connection.MultiTransferSleepEnabled = true;
connection.MultiTransferSleepTime = 5;
by (2.7k points)
The default for TIME_WAIT on Windows is 72 seconds, so you could try that.  How many files are you transferring?  Do you have access to server logs?  Since it's the server cutting the connection, it will probably help to look at those.  The problem may not be related to ports, but perhaps some sort of transfer-limit on the server.
by (560 points)
I have just tried to set 72 seconds, but it still fails.

Actually in my each try, it fails with different number of files. So i suppose that it is not related with some sort of transfer-limit on the server.

I want to transfer 500/1000 files from ftp site to local site. Any other ways to download?
by (560 points)
By the way, we can download the directory via FileZilla. (So i suppose that it is not related with some sort of transfer-limit on the server.)
by (2.7k points)
You have a current support agreement, so can you please open a ticket in our helpdesk system (enterprisedt.com/help).  Please create a debug-level log file that illustrates the problem and attach it to your ticket.  The size-limit of attachment is only 2MB, so please zip up the log.  It would also be helpful if you could create a test project in Visual Studio and attach that as well.

Please log in or register to answer this question.

Categories

...