8 Replies Latest reply on Feb 24, 2009 3:33 PM by clebert.suconic

    unable to connect to JBM server using SSH port forwarding

    bodrin

      JBM.1.4.0.SP3 \ jboss-4.2.2.GA

      I have JBM running on host jbm. I have a standalone JBM client (consumer/producer) running on another host (say localhost) which does not see host jbm. I have ssh tunnel that port forwards localhost:1200 -> jbm:1200.
      The configuration of my standalone app is:

      java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
      java.naming.factory.url.pkgs=jboss.naming:org.jnp.interfaces
      jnp.disableDiscovery=true
      java.naming.provider.url=localhost:1200
      


      When I try to connect it to JBM server I got :
      javax.naming.CommunicationException [Root exception is java.rmi.RemoteException: Service unavailable.; nested exception is:
       java.rmi.ConnectException: Connection refused to host: jbm; nested exception is:
       java.net.ConnectException: Connection refused: connect]
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:780)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:627)
       at javax.naming.InitialContext.lookup(InitialContext.java:392)
       at com.sep.messagebus.impl.JMSLocatorImpl.getConnectionFactory(JMSLocatorImpl.java:63)
       at com.sep.messagebus.impl.JMSLocatorImpl.getQueueConnectionFactory(JMSLocatorImpl.java:73)
       at com.sep.messagebus.impl.JMSLocatorImpl.getQueueConnection(JMSLocatorImpl.java:86)
       at com.sep.messagebus.helpers.JMSLocatorWrapper.getQueueConnection(JMSLocatorWrapper.java:66)
       at com.sep.messagebus.test.process.profile.activation.QueueViewer.setupJmsResources(QueueViewer.java:86)
       at com.sep.messagebus.helpers.JMSSetupDaemon.setupJmsResources(JMSSetupDaemon.java:117)
      
      Caused by: java.rmi.RemoteException: Service unavailable.; nested exception is:
       java.rmi.ConnectException: Connection refused to host: jbm; nested exception is:
       java.net.ConnectException: Connection refused: connect
       at org.jboss.ha.framework.interfaces.HARMIClient.invokeRemote(HARMIClient.java:261)
       at org.jboss.ha.framework.interfaces.HARMIClient.invoke(HARMIClient.java:321)
       at $Proxy0.lookup(Unknown Source)
       at org.jnp.interfaces.NamingContext.lookup(NamingContext.java:667)
       ... 14 more
      Caused by: java.rmi.ConnectException: Connection refused to host: jbm; nested exception is:
       java.net.ConnectException: Connection refused: connect
       at sun.rmi.transport.tcp.TCPEndpoint.newSocket(TCPEndpoint.java:601)
       at sun.rmi.transport.tcp.TCPChannel.createConnection(TCPChannel.java:198)
       at sun.rmi.transport.tcp.TCPChannel.newConnection(TCPChannel.java:184)
       at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:110)
       at org.jboss.ha.framework.server.HARMIServerImpl_Stub.invoke(Unknown Source)
       at org.jboss.ha.framework.interfaces.HARMIClient.invokeRemote(HARMIClient.java:219)
       ... 17 more
      Caused by: java.net.ConnectException: Connection refused: 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:366)
       at java.net.Socket.connect(Socket.java:519)
       at java.net.Socket.connect(Socket.java:469)
       at java.net.Socket.<init>(Socket.java:366)
       at java.net.Socket.<init>(Socket.java:180)
       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:595)
       ... 22 more
      


      So, I have configured that my server is on localhost:1200, but it tries to connect to jbm host?
      Can I overcome this somehow?

        • 1. Re: unable to connect to JBM server using SSH port forwardin
          clebert.suconic

          http://www.jboss.org/community/docs/DOC-12519

          You would need to set the ports you use on remoting. (instead of using random ports)

          • 2. Re: unable to connect to JBM server using SSH port forwardin
            bodrin

            10x, but the information on this page doesn't help
            I have tried

            -Djava.rmi.server.hostname=<external_host_name>
             -Djava.rmi.server.useLocalHostname=true
            
            but no success .. the same exception..

            The page says:
            Open three ports through your firewall, one for the naming service, a second for the naming service RmiPort, and a third for the jrmp RMIObjectPort.

            But how to tell my client for these three ports? I have only configured
            java.naming.provider.url=localhost:1200
            


            I'm not behind a firewall, I just mimic as if the JBM server resides on some host (localhost in this case) in my LAN using port forwarding (ssh tunneling).

            Has anybody done something like this?

            • 3. Re: unable to connect to JBM server using SSH port forwardin
              gaohoward

              I don't know if localhost:1200 works or not in that case, but can you try replace localhost with the host name (or the ip address) of your client host?

              • 4. Re: unable to connect to JBM server using SSH port forwardin
                clebert.suconic

                 

                "bodrin" wrote:
                10x, but the information on this page doesn't help
                I have tried
                -Djava.rmi.server.hostname=<external_host_name>
                 -Djava.rmi.server.useLocalHostname=true
                
                but no success .. the same exception..


                Those two settings don't have any affect on JBoss.

                Look at the JBoss documentation.

                You should instead change the ports on the XML configs.

                You will also have to define the ports on remoting, as there are two random ports. (look at remoting-bisocket-service.xml):

                <!-- Use these parameters to specify values for binding and connecting control connections to
                 work with your firewall/NAT configuration
                 <attribute name="secondaryBindPort">xyz</attribute>
                 <attribute name="secondaryConnectPort">abc</attribute>
                 -->
                



                • 5. Re: unable to connect to JBM server using SSH port forwardin
                  clebert.suconic

                  All you have to do is to define the two ports on remoting (as we use random ports on that case), and open the ports you need (or forward the ports you need), according to the wiki page.

                  If you want to change any ports, you will have to change the XML configs.

                  • 6. Re: unable to connect to JBM server using SSH port forwardin
                    bodrin

                    Ok, I have two more questions.

                    1. Say that I have specified thesecondaryBindPort and secondaryConnectPort at JBM server. Then in the client LAN say I have "jbmfake" host on which I set up three port forwardings:
                    jbmfake:serverBindPort -> jbm:serverBindPort
                    jbmfake:secondaryBindPort-> jbm:secondaryBindPort
                    jbmfake:secondaryConnectPort-> jbm:secondaryConnectPort

                    The question is how to configure the client jndi props and rmi props:

                    -Djava.rmi.server.hostname=<external_host_name>
                    -Djava.rmi.server.useLocalHostname=true
                    

                    <external_host_name>=?
                    java.naming.provider.url=jbmfake:SOME_PORT
                    

                    SOME_PORT=?

                    2. The above seems to be the configuration when we have single node cluster. So what about two/three/... nodes in the cluster? Could secondaryBindPort and secondaryConnectPort be specified in
                    \docs\examples\binding-manager\sample-bindings.xml ?
                    Do I have to port forward for each node separately or a subset (like 1 node) is sufficient?


                    • 7. Re: unable to connect to JBM server using SSH port forwardin
                      timfox

                      This is all JBoss Remoting config.

                      Your best bet for questions related to that is the JBoss Remoting forum.

                      • 8. Re: unable to connect to JBM server using SSH port forwardin
                        clebert.suconic

                         

                        "clebert.suconic@jboss.com" wrote:
                        All you have to do is to define the two ports on remoting (as we use random ports on that case), and open the ports you need (or forward the ports you need), according to the wiki page.

                        If you want to change any ports, you will have to change the XML configs.


                        I already told you those settings don't have any effect on Jboss.

                        Refer to JBAS documentation, or ask on the jboss forum. This is about configuring the JNDI ports.