Free Support Forum -

FtpClient.Disconnect does not return

Hi Forum,

I use Aspose.Network for uploading files to a FTP Server. This works fine but sometimes the Disconnect methods seems not to return.
I tried setting Command and Data timeouts but without any effect. Also i tried assigning TransferBroken and Complete Eventhanlder to check if there is a problem but the upload always fnishes but the Disconnect method is the last heartbeat I can see in the logs.

Windows XP SP3 running my console application.

Ftp Client Init

Aspose.Network.Ftp.FtpClient lClient = new Aspose.Network.Ftp.FtpClient(ConfigurationManager.AppSettings.Get(“FtpServer”), ConfigurationManager.AppSettings.Get(“FtpUserName”), ConfigurationManager.AppSettings.Get(“FtpPassword”));

lClient.DataReceiveTimeout = 5000;
lClient.DataSendTimeout = 5000;
lClient.CommandReceiveTimeout = 5000;
lClient.CommandSendTimeout = 5000;
lClient.DataConnectionMode = DataConnectionMode.Passive;

lClient.TransferBroken += TransferBrokenEvent;
lClient.TransferCompleted += TransferCompleteEvent;
lClient.TransferProgress += TransferProgressEvent;


log.Debug(“UploadMonitor.NewExportFolderListAvailable(): FTP Logged in. Transfer starting…”);
lClient.TransferType = Aspose.Network.Ftp.TransferType.Binary;
lClient.UploadMultiFiles(current.FullName, “.”, true);
log.Debug(“UploadMonitor.NewExportFolderListAvailable(): FTP Transfer complete.”);
if (lClient.Connected)
log.Debug(“UploadMonitor.NewExportFolderListAvailable(): Invoke disconnect.”);
log.Debug(“UploadMonitor.NewExportFolderListAvailable(): Done.”);
log.Debug(“UploadMonitor.NewExportFolderListAvailable(): Already disconnected.”);
log.Debug(“UploadMonitor.NewExportFolderListAvailable(): FTP Connection closed.”);

All this happens inside a try/catch but no exception is thrown.
All this happens inside a foreach loop, could it be that i have to null the instance of the ftp client?

Update, tried this with the latest Aspose.Network version but this did not change behavior.

The target FTP Server is vsFTPd 2.0.7. running under Debian


Thank you for inquiry.

Could you please try to move the Disconnect() call to the finally block and see if it works this way?

FtpClient lClient = null;

// initialize, connect, upload, download etc
catch(Exception ex)
// handle exception
lClient.Dispose(); // try adding this too


thanks for your reply. Disposing the Client did the trick. So far the error did not reoccur.