Archived Forum Post

Index of archived forum posts


Keep SSH Tunnel Alive/Running

Aug 12 '16 at 00:45

Hi I'm trying to setup a simple SSH Tunnel client software with dynamic port forwarding.

I'm doing it in

But I'm unable to keep the SSH Tunnel alive, it disconnects as soon as the procedure/function runs, i want to keep it running and use it a browser on my PC as proxy, how can i achieve it ?

I don't want the SSH Tunnel to disconnect till i want to disconnect it



Well basically it was just my fault

I'm on MAC and using Parallels Desktop for Development, i was testing it using a browser on Mac rather then running a browser inside the VM


Make sure you're using the latest version of Chilkat..


The SshTunnel can operate in two different ways. The first way is to set a hard-coded destination host:port, such as what is done in the code above.

 m_SSH.DestHostname = m_sTunnelRemoteAddr
 m_SSH.DestPort = m_iTunnelRemotePort

This is reasonable if all communications are directed to a single location, such as a database server.

However, HTTP traffic would need to be directed to many locations. For that, you use SshTunnel in the second way -- with dynamic port forwarding. You don't set DestHostname or DestPort. Instead, you do this:

// Indicate that the background SSH tunnel thread will behave as a SOCKS proxy server // with dynamic port forwarding: tunnel.DynamicPortForwarding = true;

// We may optionally require that connecting clients authenticate with our SOCKS proxy server. // To do this, set an inbound username/password. Any connecting clients would be required to // use SOCKS5 with the correct username/password. // If no inbound username/password is set, then our SOCKS proxy server will accept both // SOCKS4 and SOCKS5 unauthenticated connections.

tunnel.InboundSocksUsername = "chilkat123"; tunnel.InboundSocksPassword = "password123";

See the example here:


Hi I do understand about dynamic port forwarding, i've used exact same code as given in example but the problem is as soon as the procedure/function ends even tunnel stops, i want to keep it running, i just don't understand how to do that



Hera are some logs:

ChilkatLog: BeginAccepting: DllDate: Jun 13 2016 ChilkatVersion: UnlockPrefix: xxxxxx Architecture: Little Endian; 32-bit Language: .NET 4.5 VerboseLogging: 0 listenPort: 1080 dynamicPortForwarding: 1 Listen thread started. AllocatedListenPort: 1080 Success. --BeginAccepting --ChilkatLog

As you can see it connects but then it stops, moreover i'm not closing or stopping tunnel anywhere


Hi Issue is resolved