Archived Forum Post

Index of archived forum posts

Question:

TCP/IP connection failed to establish for a tunnel inside another tunnel

Jul 16 '15 at 02:28

I am developing an android application for which I need to do Ssh multiple port forwarding. I have opened an Ssh tunnel within already opened Ssh tunnel. But the connection is not being established Here is my code :

 protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

    CkSocket tunnel = new CkSocket();

    boolean success;

    //  Anything unlocks the component and begins a fully-functional 30-day trial.
    success = tunnel.UnlockComponent("Anything for 30-day trial");
    if (success != true) {
        Log.i(TAG, tunnel.lastErrorText());
        return;
    }

    String sshHostname1 = "IP1";
    int sshPort1 = port1;
    success=tunnel.SshOpenTunnel(sshHostname1,sshPort1);
    if (success != true) {
        Log.i(TAG, tunnel.lastErrorText());
        System.out.println("error in estab conn");
        return;
    }
    success = tunnel.SshAuthenticatePw("uname", "pwd");
    if (success != true) {
        Log.i(TAG, tunnel.lastErrorText());
        System.out.println("login error");
        return;
    }
    System.out.println("opened 1st tunnel");

    String sshHostname2 = "IP2";
    int sshPort2 = port2;
    success=tunnel.SshOpenTunnel("sshHostname2",sshPort2);
    if (success != true) {
        Log.i(TAG, tunnel.lastErrorText());
        System.out.println("error in est conn");
        return;
    }
    success = tunnel.SshAuthenticatePw("u2", "p2");
    if (success != true) {
        Log.i(TAG, tunnel.lastErrorText());
        System.out.println("login error");
        return;
    }
    System.out.println("opened 3rd tunnel");

} static { // Important: Make sure the name passed to loadLibrary matches the shared library // found in your project's libs/armeabi directory. // for "libchilkat.so", pass "chilkat" to loadLibrary // for "libchilkatemail.so", pass "chilkatemail" to loadLibrary // etc. // System.loadLibrary("chilkat");

    // Note: If the incorrect library name is passed to System.loadLibrary,
    // then you will see the following error message at application startup:
    //"The application <your-application-name> has stopped unexpectedly. Please try again."
}

1st tunnel is opening, but error is thrown on attempting to open 2nd tunnel. Here is the error log:
    SshOpenTunnel:
    DllDate: Jun 23 2015
    ChilkatVersion: 9.5.0.51
    UnlockPrefix: Anything for 30-day trial
    Architecture: Little Endian; 32-bit
    Language: Android Java
    VerboseLogging: 0
    objectId: 1
    sshOpenTunnel:
    sshHostname: 10.215.9.15
    port: 22
    sshTunnel:
    tunnelIdleTimeoutMs: 0
    tunnelConnectTimeoutMs: 30000
    sshConnect:
    connectSocket:
    connect_ipv6_or_ipv4:
    timeout waiting for connect to complete
    numSec: 30
    numMicroSec: 0
    failedWaitToConnect: Socket operation timeout.
    --connect_ipv6_or_ipv4
    --connectSocket
    Failed to establish initial TCP/IP connection
    --sshConnect
    --sshTunnel
    --sshOpenTunnel
    Failed.
    --SshOpenTunnel
    --ChilkatLog
07-15 11:13:34.753    8432-8432/System.outīš• error in est conn


Accepted Answer

Here is an example of theoretically how it should work. I just wrote this example and haven't had time yet to test..

Android: SSH Tunnel Inside another SSH Tunnel

C: SSH Tunnel Inside another SSH Tunnel

C#: SSH Tunnel Inside another SSH Tunnel

C# WinRT: SSH Tunnel Inside another SSH Tunnel

C++: SSH Tunnel Inside another SSH Tunnel

Classic ASP: SSH Tunnel Inside another SSH Tunnel

DataFlex: SSH Tunnel Inside another SSH Tunnel

Delphi ActiveX: SSH Tunnel Inside another SSH Tunnel

Delphi DLL: SSH Tunnel Inside another SSH Tunnel

Java: SSH Tunnel Inside another SSH Tunnel

Lianja: SSH Tunnel Inside another SSH Tunnel

MFC: SSH Tunnel Inside another SSH Tunnel

Objective-C: SSH Tunnel Inside another SSH Tunnel

Perl: SSH Tunnel Inside another SSH Tunnel

PHP ActiveX: SSH Tunnel Inside another SSH Tunnel

PHP Extension: SSH Tunnel Inside another SSH Tunnel

PowerBuilder: SSH Tunnel Inside another SSH Tunnel

PowerShell: SSH Tunnel Inside another SSH Tunnel

PureBasic: SSH Tunnel Inside another SSH Tunnel

Python: SSH Tunnel Inside another SSH Tunnel

Ruby: SSH Tunnel Inside another SSH Tunnel

SQL Server: SSH Tunnel Inside another SSH Tunnel

Swift: SSH Tunnel Inside another SSH Tunnel

Unicode C: SSH Tunnel Inside another SSH Tunnel

Unicode C++: SSH Tunnel Inside another SSH Tunnel

VB.NET: SSH Tunnel Inside another SSH Tunnel

VB.NET WinRT: SSH Tunnel Inside another SSH Tunnel

VBScript: SSH Tunnel Inside another SSH Tunnel

Visual Basic 6.0: SSH Tunnel Inside another SSH Tunnel

Visual FoxPro: SSH Tunnel Inside another SSH Tunnel