You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We have multiple Cisco devices in our system which need to be tested in every 24 hours. For testing, we use a C# application which picks up one device at a time from queue for testing. To connect to these devices, we are using Renci library to setup a SSH connection and run commands on these devices. While SSH connection for the first device completes successfully, the connection keeps failing for the rest of the devices in queue until the application is restarted.
Say, we have 10 devices in Queue:
Device 1 => Connection successful
Device 2 => Connection fails
Device 3 => Connection fails
...
...
Device 10 => Connection fails
Code sample for reference:
private static string h = string.Empty;
private static string u = string.Empty;
private static string p = string.Empty;
public static void RunTest(string DeviceName, string userName, string pswd)
{
h = DeviceName;
u = userName;
p = pswd;
ConnectionInfo ConnInfo = new ConnectionInfo(h, 22, u, new AuthenticationMethod[]
{
new PasswordAuthenticationMethod(u, p),
});
using (var client = new SshClient(ConnInfo))
{
client.Connect();
using (var stream = client.CreateShellStream("", 80, 40, 80, 40, 1024))
{
// Run command
command = "<Command 1>";
stream.WriteLine(command);
command = "<Command 2>";
stream.WriteLine(command);
...
command = "<Command 20>";
stream.WriteLine(command);
// Read Output
output = stream.Read();
// Print Output
...
stream.Dispose();
}
client.Disconnect();
client.Dispose();
}
}
Error Message:
23:11:46 INFO: Renci.SshNet.Common.SshOperationTimeoutException: Session operation has timed out
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout)
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle)
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.CreateAndConnectSession()
at Renci.SshNet.BaseClient.Connect()
The text was updated successfully, but these errors were encountered:
I experienced exactly this issue when periodically reconnecting to the same Cisco router. The first connection would always work; subsequent connections would (almost) always fail with SshOperationTimeoutException.
Issue:
We have multiple Cisco devices in our system which need to be tested in every 24 hours. For testing, we use a C# application which picks up one device at a time from queue for testing. To connect to these devices, we are using Renci library to setup a SSH connection and run commands on these devices. While SSH connection for the first device completes successfully, the connection keeps failing for the rest of the devices in queue until the application is restarted.
Say, we have 10 devices in Queue:
...
...
Code sample for reference:
Error Message:
23:11:46 INFO: Renci.SshNet.Common.SshOperationTimeoutException: Session operation has timed out
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle, TimeSpan timeout)
at Renci.SshNet.Session.WaitOnHandle(WaitHandle waitHandle)
at Renci.SshNet.Session.Connect()
at Renci.SshNet.BaseClient.CreateAndConnectSession()
at Renci.SshNet.BaseClient.Connect()
The text was updated successfully, but these errors were encountered: