sshnet / SSH.NET

SSH.NET is a Secure Shell (SSH) library for .NET, optimized for parallelism.
http://sshnet.github.io/SSH.NET/
MIT License
3.88k stars 919 forks source link

ForwardedPortRemote not closing the local TCP socket. #326

Open ljruiten opened 6 years ago

ljruiten commented 6 years ago

I am using SSH.NET to create a reverse tunnel to a Linux server so that I am able to connect to a VNC server behind a NAT. There is also a monitoring program running that checks whether someone is actually connected to the VNC server. This is checked using the following piece of code:

int clients = IPGlobalProperties
    .GetIPGlobalProperties()
    .GetActiveTcpConnections()
    .Where((c) => c.LocalEndPoint.Port == monitorPort)
    .Count();

(monitorPort is 5900, so the port VNC server is listening on)

Using our old reverse tunneling system, this worked fine. But with SSH.NET the amount of clients never decrease. It seems that SSH.NET keeps the socket to the VNC server open forever.

So I would say that this is a bug in SSH.NET right? The expected behavior would be that the socket closes immediately after the client disconnects.

If you need more info, please let me know. Will have a look at the source code myself tomorrow. Kind regards, LJ

ljruiten commented 5 years ago

Anyone? This is still a big bug.