If the connection is lost while we're waiting in ShellStream.Expect(), Expect() doesn't wake up, either hanging forever or until the timeout elapses.
Here's a simple repro. I configured the target server (a Cisco NCS-5K) to end sessions that have been idle for 30 seconds, and then I set an expect that never matches. The connection dies 30 seconds in, but the Supercalifragilisticexpialidocious Expect waits 5 excruciating minutes to return:
varssh=newSshClient(info);ssh.Connect();using(varshell=ssh.CreateShellStream("xterm",80,80,80,80,1024)){shell.Expect("#",TimeSpan.FromSeconds(30));Trace.TraceInformation("Shell has started!");vartime=Stopwatch.StartNew();varresult=shell.Expect("Supercalifragilisticexpialidocious!",TimeSpan.FromMinutes(5));Trace.TraceInformation($"Shell took {time.Elapsed} to time out..");}Expect() should return immediately upon disconnect.
If the connection is lost while we're waiting in
ShellStream.Expect(), Expect() doesn't wake up, either hanging forever or until the timeout elapses.Here's a simple repro. I configured the target server (a Cisco NCS-5K) to end sessions that have been idle for 30 seconds, and then I set an expect that never matches. The connection dies 30 seconds in, but the Supercalifragilisticexpialidocious Expect waits 5 excruciating minutes to return:
Expect() should return immediately upon disconnect.