FTP Keep Alive

Could you improve Aspose.Ftp so that the Keep Alive happens automatically based on a new KeepAliveInterval property? You would also need a new property "UseKeepAlive" so that people can determine if they want to use Ftp Keep Alive functionality.

Let me know how much time this will take.

Thanks!
Dan

Hello Dan,

Thank you for your support!

Actualy, this is good idea, and we did think about letting KeepAlive() method has an option for permanant KeepAlive. We will discuss it and get back to you soon, hopefuly in a couple of days. But if you need this feature urgently, please tell me. We will provide some samples to do so using the current version of Network.

Best regards

An example would be great, although I am using threading with Aspose.Ftp AND the Keep Alive which seems to cause some problems. If you can keep this in mind when sending the example code, that would be helpful.

Thanks!

Dan

hello Dan,

Thank you for your support!

In the following sample I use a timer to call KeepAlive() periodically. Timer settings is in init() method. Does it work for you?

[VB.NET]
Dim client As Aspose.Network.Ftp.FtpClient = Nothing
Dim WithEvents timer As System.Timers.Timer = Nothing

Sub init()
'keep alive every 60 seconds
timer = New System.Timers.Timer(60000)
timer.Enabled = False
client = New Aspose.Network.Ftp.FtpClient("192.168.18.101", 21, "anonymous", "password")
Try
client.Connect(True)
timer.Enabled = True
Catch ex As Exception
End Try
End Sub
    Sub timer_elapsed(ByVal sender As Object, ByVal args As System.Timers.ElapsedEventArgs) Handles timer.Elapsed
Try
If client Is Nothing Then
Exit Sub
ElseIf client.Connected Then
client.KeepAlive()
Else
client.Connect(True)
End If
Catch ex As Exception
End Try
End Sub
[C#]
static System.Timers.Timer timer = null;
static Aspose.Network.Ftp.FtpClient client = null;
  private static void init()
{
timer = new System.Timers.Timer(2000);
timer.Enabled = false;
client = new Aspose.Network.Ftp.FtpClient("192.168.18.101", 21, "anonymous", "password");
timer.Elapsed +=new System.Timers.ElapsedEventHandler(timer_Elapsed);
try
{
client.Connect(true);
timer.Enabled = true;
}
catch(Exception ex)
{}
}
  private static void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
try
{
if(client == null)
{
return;
}
else if(client.Connected)
{
client.KeepAlive();
}
else
{
client.Connect(true);
}
}
catch(Exception ex)
{}
}

Best Regards!