I was testing ssh.net with 2 ForwardedPortLocals. When a connection is established, a port is forwarded properly but the channel is sometimes not closed, depending on how the local port was closed.
It can get stuck waiting for an EOF that never comes in ChannelDirectTcpip.cs Bind()
System.Threading.WaitHandle.WaitAny(new WaitHandle[] { this._channelEof });
this is because the while loop above can exit gracefully if _socket.CanRead() returns false. In this scenario no CloseMessage was ever sent so it will sit waiting forever. I suggest adding:
this.SendMessage( new ChannelCloseMessage( this.RemoteChannelNumber ) );
after the while loop or moving the WaitAny line into Close();
It can get stuck waiting for an EOF that never comes in ChannelDirectTcpip.cs Bind()
System.Threading.WaitHandle.WaitAny(new WaitHandle[] { this._channelEof });
this is because the while loop above can exit gracefully if _socket.CanRead() returns false. In this scenario no CloseMessage was ever sent so it will sit waiting forever. I suggest adding:
this.SendMessage( new ChannelCloseMessage( this.RemoteChannelNumber ) );
after the while loop or moving the WaitAny line into Close();