5 Replies Latest reply on Jun 21, 2017 1:26 PM by jasonglass

    Cannot connect to HornetQ via Remote call when wildfly 8.1.0 install is behind a NAT

    juice0123

      Cannot connect to jms via Remote call when wildfly 8.1.0 installs are on a different subnet. I currently have this working on the same subnet. I can connect when on the same subnet, but when on a different subnet, it fails to create the connection. The following is the method i use that works on the same subnet and breaks on a different subnet.

                

                      final Properties env = new Properties();

                      env.put(Context.INITIAL_CONTEXT_FACTORY, "org.jboss.naming.remote.client.InitialContextFactory");

                      env.put(Context.PROVIDER_URL, System.getProperty(Context.PROVIDER_URL, "http-remoting://" + ip + ":" + port));

                      env.put(Context.SECURITY_PRINCIPAL, System.getProperty("username", User));

                      env.put(Context.SECURITY_CREDENTIALS, System.getProperty("password", Password));

                      initialContext = new InitialContext(env);

       

                     //The next two lines work

                      ConnectionFactory cf = (ConnectionFactory) initialContext.lookup("jms/RemoteConnectionFactory");

                      Destination destination = (Destination) initialContext.lookup("java:/jms/queue/" + queueName);

       

                    //fails here, cannot create the connection

                      Connection connection = cf.createConnection(User, Password);

       

                      Session session = connection.createSession(false, Session.AUTO_ACKNOWLEDGE);

                      MessageProducer producer = session.createProducer(destination);

                      connection.start();

       

      I had this working on jboss 5.1.0 sending to remote queue messages to the queue on a jboss7.1.2 install, but only with the host file on the client machine changed to reflect the host name of the machine to its ip. I have ported both servers the wildfly 8.1.0 and I can't get it working across different subnets. I keep getting the following error


      javax.jms.JMSException: Failed to create session factory

      Caused by: HornetQNotConnectedException[errorType=NOT_CONNECTED message=HQ119007: Cannot connect to server(s). Tried with all available servers.]

        at org.hornetq.core.client.impl.ServerLocatorImpl.createSessionFactory(ServerLocatorImpl.java:905) [jboss-client-8.1.jar:8.1.0.Final]

        at org.hornetq.jms.client.HornetQConnectionFactory.createConnectionInternal(HornetQConnectionFactory.java:669) [jboss-client-8.1.jar:8.1.0.Final]


      Any Ideas?

        • 1. Re: Cannot connect to HornetQ via Remote call when wildfly 8.1.0 installs are on a different subnets
          jbertram

          Can you paste the configuration of your "jms/RemoteConnectionFactory"?

          • 2. Re: Cannot connect to HornetQ via Remote call when wildfly 8.1.0 installs are on a different subnets
            juice0123

            Is this what you are looking for ?

             

            <jms-connection-factories>

                                <connection-factory name="InVmConnectionFactory">

                                    <connectors>

                                        <connector-ref connector-name="in-vm"/>

                                    </connectors>

                                    <entries>

                                        <entry name="java:/ConnectionFactory"/>

                                    </entries>

                                </connection-factory>

                                <connection-factory name="RemoteConnectionFactory">

                                    <connectors>

                                        <connector-ref connector-name="http-connector"/>

                                    </connectors>

                                    <entries>

                                        <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>

                                    </entries>

                                </connection-factory>

                                <pooled-connection-factory name="hornetq-ra">

                                    <transaction mode="xa"/>

                                    <connectors>

                                        <connector-ref connector-name="in-vm"/>

                                    </connectors>

                                    <entries>

                                        <entry name="java:/JmsXA"/>

                                        <entry name="java:jboss/DefaultJMSConnectionFactory"/>

                                    </entries>

                                </pooled-connection-factory>

                            </jms-connection-factories>

             

            I think i might have discovered the problem. My wildfly server is behind a NAT, so the ip address that i bind wildfly to, is not the same address that the client is sending the data to teh queue to. For instance. X is the client and Y is the server. X sends to address 1.1.1.1 ..... through NAT it sends the data to 2.2.2.2  on server Y. I think this may be the issue.

            • 3. Re: Cannot connect to HornetQ via Remote call when wildfly 8.1.0 install is behind a NAT
              jasonglass

              Hi Juice!  I'm having the same problem and wondering how you were able to resolve it?  I'm digging around through other posts but havent found a more recent solution!  Any help would be appreciated!

              • 4. Re: Cannot connect to HornetQ via Remote call when wildfly 8.1.0 install is behind a NAT
                jbertram

                Please create a new thread with a full explanation of your use-case and problem and I'll try to help.  If the problem is with NAT then it should be pretty simple to resolve.

                • 5. Re: Cannot connect to HornetQ via Remote call when wildfly 8.1.0 install is behind a NAT
                  jasonglass

                  Here you go Justin!
                  JMS Message Queue, NAT'ed IP - change ?advertised? address

                  I'm also trying the JBoss 7 fixes but none seem to be working, e.g. the link at the bottom!

                   

                  Thank you!