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.

Aspose.Network 5.8.0.0
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;

lClient.Connect(true);

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.”);
lClient.Disconnect();
log.Debug(“UploadMonitor.NewExportFolderListAvailable(): Done.”);
}
else
{
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 6.4.0.0 but this did not change behavior.

The target FTP Server is vsFTPd 2.0.7. running under Debian

Hi,

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;

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

Hi,

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

Thanks
Karl