Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: Create an SSH tunnel

$
0
0
If you use the same code as some posts above, of course the tunnel is closed.
You are disposing the client object after port.Start(), thats what a using is block is for.

Just don't use using.

Maybe something like this:
SshClient client;

public void Start()
{
      client = new SshClient("vps97919.ovh.net", "tunnel", "123456")
      client.KeepAliveInterval = new TimeSpan(0, 0, 30);
      client.ConnectionInfo.Timeout = new TimeSpan(0, 0, 20);
      client.Connect();
      ForwardedPortDynamic port = new ForwardedPortDynamic("127.0.0.1", 1080);
      client.AddForwardedPort(port);
      port.Start();
}

public void Stop()
{
      client.Disconnect(); 
}
Just an example, to show the problem with your code.

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>