Do we have a event to notify when ssh connection is broken?
I use the Rebex.Ssh-Lib to establish a ssh-tunnel.
How can I be informed when the tunnel is broken, e.g. wifi is lost?
I try this:
var ssh = new Rebex.Net.Ssh();
ssh.Connect(destIp.ToString(), remotePort);
ssh.Login(..., ...);
var tunnel = ssh.StartOutgoingTunnel(
sshLocalhost.ToString(), 0,
sshLocalhost.ToString(), remotePort);
Task.Run(async () =>
{
while (true)
{
await Task.Delay(1000);
ssh.CheckConnectionState();
var cs = _ssh.GetConnectionState();
Console.WriteLine($"Error:{cs.NativeErrorCode} | IsConnected:{cs.Connected}");
}
});
The output is alway Error:0 | true
How can I reliable check the connectionstate?