Menu

Using SSH tunnel to connect MC4J to Tomcat

Help
2005-05-24
2013-04-25
  • Richard Mixon

    Richard Mixon - 2005-05-24

    I am trying to connect to my production Tomcat server over an ssh tunnel.

    First, I can run MC4J as an X application from the server with the X server running on my workstation fine. I connect to the localhost over port 9004.

    To connect using tunnelling, I start a putty session redirecting localhost:9004 on my workstation to localhost:9004 on the production server.

    However when I try and make the connection using MC4J, I get the following in my Putty event log:

    2005-05-24 16:39:44    Local port 9004 forwarding to localhost:9004
    2005-05-24 16:39:44    Allocated pty (ospeed 38400bps, ispeed 38400bps)
    2005-05-24 16:39:44    Started session
    2005-05-24 16:40:21    Opening forwarded connection to localhost:9004
    2005-05-24 16:41:06    Forwarded port closed

    And MC4J fails to connect, showing the following dialog/exception:

    java.rmi.ConnectException: Connection refused to host: 140.99.50.60; nested exception is:
        java.net.ConnectException: Connection timed out: connect
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:574)
        at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:185)
        at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:171)
        at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:94)
        at javax.management.remote.rmi.RMIServerImpl_Stub.newClient(Unknown Source)
        at javax.management.remote.rmi.RMIConnector.getConnection(RMIConnector.java:2229)
        at javax.management.remote.rmi.RMIConnector.connect(RMIConnector.java:271)
        at javax.management.remote.JMXConnectorFactory.connect(JMXConnectorFactory.java:248)
        at org.mc4j.console.connection.JSR160ConnectionNode.connect(JSR160ConnectionNode.java:132)
        at org.mc4j.console.connection.ReconnectAction.performAction(ReconnectAction.java:47)
        at org.openide.util.actions.NodeAction$3.run(NodeAction.java:440)
        at org.openide.util.actions.CallableSystemAction$ActionRunnable.actionPerformed(CallableSystemAction.java:247)
        at org.netbeans.core.ModuleActions.invokeAction(ModuleActions.java:74)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:585)
        at org.openide.util.actions.CallableSystemAction.invokeAction(CallableSystemAction.java:179)
        at org.openide.util.actions.CallableSystemAction.access$000(CallableSystemAction.java:31)
        at org.openide.util.actions.CallableSystemAction$ActionRunnable.doRun(CallableSystemAction.java:241)
        at org.openide.util.actions.CallableSystemAction$2.run(CallableSystemAction.java:111)
        at org.openide.util.Task.run(Task.java:136)
        at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:330)
        at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:686)
    Caused by: java.net.ConnectException: Connection timed out: connect
        at java.net.PlainSocketImpl.socketConnect(Native Method)
        at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
        at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
        at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364)
        at java.net.Socket.connect(Socket.java:507)
        at java.net.Socket.connect(Socket.java:457)
        at java.net.Socket.<init>(Socket.java:365)
        at java.net.Socket.<init>(Socket.java:178)
        at sun.rmi.transport.proxy.RMIDirectSocketFactory.createSocket(RMIDirectSocketFactory.java:22)
        at sun.rmi.transport.proxy.RMIMasterSocketFactory.createSocket(RMIMasterSocketFactory.java:128)
        at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:569)
    [catch] ... 23 more

    Any ideas on how to make this work? Does JMX do something different that prevents port forwarding from working?

    BTW, X sesson forwarding works just fine with putty. And I have used Putty port forwarding to forward Tomcat localhost:8080 ton my server to localhost:8080 on my workstation - works fine.

    Thank you - Richard

     
    • Justin Knowlden

      Justin Knowlden - 2005-06-28

      I am having a similar problem connecting to a Weblogic 8.1 instance through a SSH Tunnel. MC4J connects fine to a local WebLogic instance. Port forwarding works fine when connecting to the console on the remote WebLogic instance, but MC4J cannot connect to the remote server through a tunnel.

      I debugged my SSH connection using "-v" and did not see any problems. However, when I checked the output of the WebLogic Admin server, I found the following error (proprietary names replaced with generic values):

      <Jun 28, 2005 10:09:32 AM CDT> <Error> <RJVM> <BEA-000572> <The server rejected a connection attempt JVMMessage from: '-8456131634567030137C:127.0.0.1R:-7384393398538614943S:internal-host:[9009,9009,-1,-1,9009,-1,-1,0,0]:wl-domain:wl-server' to: '0S:127.0.0.1:[12121,-1,-1,-1,-1,-1,-1,-1,-1]' cmd: 'CMD_IDENTIFY_REQUEST', QOS: '101', responseId: '0', invokableId: '0', flags: 'JVMIDs Sent, TX Context Not Sent', abbrev offset: '228' probably due to an incorrect firewall configuration or admin command.>

      I see this error each time I try to connect to that server with MC4j through the tunnel. In my mind, the important message is "'JVMIDs Sent, TX Context Not Sent'".

      Is MC4J trying to open on another port? I tried sniffing my connections but found nothing out of the ordinary. Any help is much appreciated.

       

Log in to post a comment.