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.
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.
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.
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