I use renci.sshnet in a multi-threaded/multi-concurrent-connection environment and was observing randome generic exceptions being thrown during heavy testing.
> Using Revision: 28765
The problem was found in Session.cs lines 637 through 646:
```
switch (EventWaitHandle.WaitAny(waitHandles, this.ConnectionInfo.Timeout))
{
// case 0:
// throw this._exception;
case System.Threading.WaitHandle.WaitTimeout:
this.SendDisconnect(DisconnectReason.ByApplication, "Operation timeout");
throw new SshOperationTimeoutException("Session operation has timed out");
default:
break;
}
```
With lines 639 and 670, here commented out, the random general exception was no longer thrown. Upon inspection it was found that the __WaitAny()__ call returns a zero base index to the event handle, in the passed in array of handles, that caused the wait to release. Thus, zero is a valid return value implying wait success. It should not have thrown an exception.
Comments: ** Comment from web user: JohnRo **
> Using Revision: 28765
The problem was found in Session.cs lines 637 through 646:
```
switch (EventWaitHandle.WaitAny(waitHandles, this.ConnectionInfo.Timeout))
{
// case 0:
// throw this._exception;
case System.Threading.WaitHandle.WaitTimeout:
this.SendDisconnect(DisconnectReason.ByApplication, "Operation timeout");
throw new SshOperationTimeoutException("Session operation has timed out");
default:
break;
}
```
With lines 639 and 670, here commented out, the random general exception was no longer thrown. Upon inspection it was found that the __WaitAny()__ call returns a zero base index to the event handle, in the passed in array of handles, that caused the wait to release. Thus, zero is a valid return value implying wait success. It should not have thrown an exception.
Comments: ** Comment from web user: JohnRo **
Since we applied the set of proposed fixes to our copy of the pre-beta code base (see below) the solution has been stable for us and we have not needed to freshen the code. We are in an "if it isn't broken, don't fix it" mode and do not expect to upgrade the code to the latest beta (apologies).
https://sshnet.codeplex.com/workitem/1756
https://sshnet.codeplex.com/workitem/1758
https://sshnet.codeplex.com/workitem/1759
https://sshnet.codeplex.com/workitem/1760