Error in Sends keep-alive message to the server

Jan 30, 2014 at 11:29 PM
Edited Jan 31, 2014 at 4:34 PM
Hello,

In my code when I use KeepAliveInterval connection loss occurs if the application is finished with a signature of exception "An established connection was aborted by the software on the host computer" on SendKeepAlive.
f_sshTunnel = New SshNet.SshClient(g_clsIni.ServidorSSH, CInt(g_clsIni.PortaSSH), g_clsIni.UsuarioSSH, g_clsIni.SenhaSSH)
f_sshTunnel.ConnectionInfo.Timeout = TimeSpan.FromSeconds(30)
f_sshTunnel.KeepAliveInterval = New TimeSpan(0, 0, 60)
f_sshTunnel.Connect()

f_strTunnelRemotoServer = CStr(f_intRandonPort)
f_sshPortForwardRemote = New SshNet.ForwardedPortRemote(g_clsIni.Loopback, CUInt(f_strTunnelRemotoServer), g_clsIni.Loopback, CUInt(f_strTunnelRemoto))
f_sshTunnel.AddForwardedPort(f_sshPortForwardRemote)
f_sshPortForwardRemote.Start()
f_sshTunnel.SendKeepAlive()
Debugging the source code of the library and my code together Renci exception occurs in BaseClient.cs. If the connection is lost with the still active session an error occurs during the execution of SendKeepAlive.
        /// <summary>
        /// Sends keep-alive message to the server.
        /// </summary>
        public void SendKeepAlive()
        {
            
            if (this.Session == null)
                return;

            if (!this.Session.IsConnected)
                return;

            this.Session.SendKeepAlive();

        }
I put a "try" to ignore the error, but I wonder what the best solution?
        /// <summary>
        /// Sends keep-alive message to the server.
        /// </summary>
        public void SendKeepAlive()
        {
            try
            {
                if (this.Session == null)
                    return;

                if (!this.Session.IsConnected)
                    return;

                this.Session.SendKeepAlive();
            }
            catch
            {
            }
        }
Marcelo