Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.6k views
in .NET FTP by (120 points)
Hi there ... we're working with edtFTPnet (commercial version), and have the following code, which I believe, should very simply ... connect to the ftp server, pull down a file, and then close the connection.

Unfortunately, it takes a "while" for the connection to close. When running this chunk of code on several files, because of the time to close the file, we run out of ftp connections, and the ftp server ends up hanging or not responding. We've tested this with our primary target environment (an IBM Ace ftp server), as well as Windows and linux ftp servers. In all cases, the connection can take a while to close.

How do we close the connection ... immediately?

            try
            {

                ExFTPConnection ftpConnection = new ExFTPConnection();

                ftpConnection.LicenseOwner = "XXXX";
                ftpConnection.LicenseKey = "YYYY";

                ftpConnection.ServerAddress = serverAddress;
                ftpConnection.ServerPort = serverPort;
                ftpConnection.UserName = userName;
                ftpConnection.Password = password;

                ftpConnection.Connect();

                ftpConnection.DownloadFile(pathLocalFile, pathFTPFile);
                
                log.Info("pathFTPFile: " + pathFTPFile);
                log.Info("Downloaded file '" + pathLocalFile + "'");

                ftpConnection.Close(true);
            }
            catch (Exception e)
            {
      .....

1 Answer

0 votes
by (51.6k points)
Close(true) should close the socket immediately. How did you find out that it is not closing the socket immediately?

- Hans (EnterpriseDT)

Categories

...