Question:
i'm already able to use the class CkSshTunnel and create a local socks server that download data using the ssh server as proxy. I'm using the DynamicPortForwarding idea. My code looks more or less like this:
CkSshTunnel tunnel = new CkSshTunnel(); String sshHostname = "SSH_HOST"; int sshPort = SSH_PORT; // Connect to an SSH server and establish the SSH tunnel: success = tunnel.Connect(sshHostname, sshPort); if (success != true) { System.out.println(tunnel.lastErrorText()); return; } // Authenticate with the SSH server via a login/password // or with a public key. // This example demonstrates SSH password authentication. success = tunnel.AuthenticatePw("SSH_USER","SSH_PASS"); if (success != true) { System.out.println(tunnel.lastErrorText()); return; } tunnel.put_SocksVersion(5); tunnel.put_InboundSocksUsername(null); tunnel.put_InboundSocksPassword(null); tunnel.put_DynamicPortForwarding(true); // Start the listen/accept thread to begin accepting SOCKS proxy client connections. Boolean success = tunnel.BeginAccepting(10001); Thread.sleep(100000); ...
Well, the conection is created sucessfuly and the socks server start to accept conections BUG, once the first conections are made, seems that the server close it and dont let the backgound thread do more downloads :/
My idea is let it runing so multiple and simultaneus requests can be made.
Anyone have an ideia why the tunnel closes?
ON the accept log, i see this:
2015-11-22T00:35:58-0300 Listen thread started
2015-11-22T00:35:58-0300 listenPort: 10001
2015-11-22T00:36:12-0300 Listen thread started
2015-11-22T00:36:12-0300 listenPort: 10001
2015-11-22T00:36:17-0300 Accepted new client connection.
2015-11-22T00:36:17-0300 socksVersion: 5
2015-11-22T00:36:17-0300 socksDestIP: www.globo.com
2015-11-22T00:36:17-0300 socksDestPort: 80
2015-11-22T00:36:17-0300 Opened dynamic port-forwarded SSH channel.
2015-11-22T00:36:17-0300 Starting client manager thread...
2015-11-22T00:36:17-0300 Client manager thread started.
2015-11-22T00:36:17-0300 Starting tunnel manager thread...
2015-11-22T00:36:17-0300 Tunnel manager thread started.
2015-11-22T00:36:17-0300 Accepted new client connection.
2015-11-22T00:36:17-0300 socksVersion: 5
2015-11-22T00:36:17-0300 socksDestIP: s.glbimg.com
2015-11-22T00:36:17-0300 socksDestPort: 80
2015-11-22T00:36:18-0300 Opened dynamic port-forwarded SSH channel.
2015-11-22T00:36:18-0300 Starting client manager thread...
2015-11-22T00:36:18-0300 Client manager thread started.
2015-11-22T00:36:18-0300 Accepted new client connection.
2015-11-22T00:36:18-0300 socksVersion: 5
2015-11-22T00:36:18-0300 socksDestIP: s.glbimg.com
2015-11-22T00:36:18-0300 socksDestPort: 80
2015-11-22T00:36:56-0300 ChilkatLog:
sshOpenChannel(37312ms):
sshOpenChannel(37312ms): Opening new SSH channel within SSH tunnel. channelType: direct-tcpip clientChannel: 102 clientInitialWindowSize: 327680 clientMaxPacketSize: 4096 directTcpHost: s.glbimg.com directTcpPort: 80 originatorIP: 192.168.1.10 originatorPort: 61112 Sent open channel request sshReadMessage(37312ms): readSshPacket: Socket operation timeout. terminateConnection(265ms): TCP connection cleanly closed by peer. Cleanly terminated TCP connection. --terminateConnection nRemaining: -1016811137 Failed to read more data on SSH connection. sshReadMessage: Socket operation timeout. sshReadMessage: Socket connection closed. --sshReadMessage Error reading channel response. Failed to open direct-tcpip channel failCode: 0 failReason: --sshOpenChannel
--sshOpenChannel
--ChilkatLog
2015-11-22T00:36:56-0300 failed to open SSH channel
2015-11-22T00:36:56-0300 Accepted new client connection.
2015-11-22T00:36:56-0300 Not yet connected to the SSH tunnel.
2015-11-22T00:36:56-0300 Accepted new client connection.
2015-11-22T00:36:56-0300 Not yet connected to the SSH tunnel.
2015-11-22T00:36:56-0300 Accepted new client connection.
2015-11-22T00:36:56-0300 Not yet connected to the SSH tunnel.
2015-11-22T00:36:56-0300 Accepted new client connection.
2015-11-22T00:36:56-0300 Not yet connected to the SSH tunnel.
2015-11-22T00:36:56-0300 Accepted new client connection.
Thanks!
Many FTP clients will limit downloads to two at a time, each on a different connection. This is to reduce the possibility the bandwidth of the client and host will get saturated.
If you are attempting to start another transfer on a connection that is already handling a transfer, I believe that is always going to cause problems.
Me too, how to fix ?