Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.7k views
in .NET FTP by (140 points)
Hi,

First of all, i got several console application that uses editftpnet for ftp downloads. Upon downloading for several hours sometimes the line of code hangs in the downloadfile function & didn't return and error in the catch event. What should I do?

m_ftp = new FTPConnection();
m_ftp.AutoLogin = true;
m_ftp.ConnectMode = EnterpriseDT.Net.Ftp.FTPConnectMode.PASV;
m_ftp.DeleteOnFailure = true;
m_ftp.EventsEnabled = true;
m_ftp.ParsingCulture = new System.Globalization.CultureInfo("");
m_ftp.Password = ***;
m_ftp.ServerAddress = null;
m_ftp.ServerPort = 21;
m_ftp.StrictReturnCodes = true;
m_ftp.Timeout = 0;
m_ftp.TransferBufferSize = 4096;
m_ftp.TransferNotifyInterval = ((long)(4096));
m_ftp.TransferType = EnterpriseDT.Net.Ftp.FTPTransferType.BINARY;
m_ftp.UserName = ***;

try
{
  m_ftp.DownloadFile(strLocalPath, strFilename);
}
catch ( Exception ex )
{
  console.writeln(ex.Message);
}

5 Answers

0 votes
by (51.6k points)
Setting the Timeout property would be a good start. This will cause an exception to be thrown after a certain number of milliseconds. Of course it would be nice to know why it is hanging. Does it happen before data is transferred, in the middle of the transfer, or after all the data has been transferred? Have you tried looking at the log for clues? You can enable logging by setting the LogLevel and LogFile properties.

- Hans (EDT)
0 votes
by (180 points)
Hans, I have experienced this hang problem also during long transfers of large files and I know it happens after all the data has been sent using the SecureFTPConection. (I checked that the data has been sent using another secure ftp program and looking at the size of the file). It seems like the clieting is blocking wait for a response from the server. ASny ideas. I am not sure setting the timeout will do anything. Isn't the timeout in that object for waiting for a new connection. Also, I forgot to mention that we were doing a file upload
0 votes
by (51.6k points)
Try setting SecureFTPConnection.ServerCompatibility to SecureFTPCompatibilityFlags.SSLDisableDataClosure. This disables SSL closure on the data channel, which is probably what's causing the hang in this case.

- Hans
0 votes
by (180 points)
Hans, it did not work. I tried writing a real short route to try and isolate the problem. The hang definitely occurs at the UploadFile method. The code is shown below:

Console.WriteLine("FTP has started");
SecureFTPConnection conn = new SecureFTPConnection();
conn.ServerAddress = ConfigurationSettings.AppSettings["ServerAddress"];
conn.ServerCompatibility=SecureFTPCompatibilityFlags.SSLDisableDataClosure;
conn.ServerPort = int.Parse(ConfigurationSettings.AppSettings["ServerPort"]);
conn.UserName = ConfigurationSettings.AppSettings["ServerUID"];
conn.Password = ConfigurationSettings.AppSettings["ServerPassword"];
conn.Protocol = FileTransferProtocol.FTPSExplicit;
conn.ServerValidation = SecureFTPServerValidationType.None;
conn.Protocol = FileTransferProtocol.FTPSExplicit;
conn.TransferType=FTPTransferType.BINARY;
conn.ConnectMode=FTPConnectMode.PASV;
conn.ServerValidation = SecureFTPServerValidationType.None;

conn.Connect();
Console.WriteLine("Connected to server");
conn.ChangeWorkingDirectory("/eriver");
Console.WriteLine("File upload starting....");
conn.UploadFile("C:\\eriver\\test\\test2.log", "test2.log",true);
conn.Close();
Console.WriteLine("File upload completed");

The test app is just a console app. The console hangs at the File upload starting.... message. I monitor the remote directory and the 8.994kb file hangs at the last byte uploads (show 8993 kb uploaded). Any other suggestions.
0 votes
by (162k points)
Ok, best to take this off line and send us an email with a log at debug level - see the Dev Guide.

Email to support at enterprisedt dott com

Categories

...