8 Replies Latest reply on Jul 19, 2011 10:57 AM by abc def

    HornetQ Server with dynamic IP-Address

    abc def Newbie

      I am using a honretq server non-clustered and stand-alone in my network and I need access from other machines, so I have to replace the host from "localhost" to its real ip-address in the config files.

       

      The problem is, that the server ip address is dynamic and it changes every morning. I dont want to update the hornetq-configuration.xml and hornetq-beans.xml every morning to the new ip address by hand.

       

      Is there any simple way to configure hornetq on startup automatically to the machines ip address?

        • 1. Re: HornetQ Server with dynamic IP-Address
          Tim Fox Master

          If you specify 0.0.0.0 as bind address in the config, it will bind to all available addresses. This is mentioned in the user manual.

          • 2. Re: HornetQ Server with dynamic IP-Address
            abc def Newbie

            I know this section in the manual.

             

            After setting the host to "0.0.0.0" all my connections from a outside client are refused. For example when I am looking up the ContextFactory:

             

            my_connectionFactory = (ConnectionFactory) my_context.lookup("/ConnectionFactory");

             

            -> Java Exception: "Connection refused to host: 0.0.0.0; nested exception is: .....[Connection refused:connect]"

             

            EDIT: The same code runs on the server machine correct. On the clients it runs correct, if I replace all entries "0.0.0.0" in the server config by the real external ip address of the server.

            • 3. Re: HornetQ Server with dynamic IP-Address
              Clebert Suconic Master

              you are probably having issues on connecting to JNDI. (lookup).

               

               

              Since you are running standalone, you should also change hornetq-beans.xml

               

               

               

                 <!-- JNDI server. Disable this if you don't want JNDI -->

                 <bean name="JNDIServer" class="org.jnp.server.Main">

                    <property name="namingInfo">

                       <inject bean="Naming"/>

                    </property>

                    <property name="port">${jnp.port:1099}</property>

                    <property name="bindAddress">${jnp.host:localhost}</property>

                    <property name="rmiPort">${jnp.rmiPort:1098}</property>

                    <property name="rmiBindAddress">${jnp.host:localhost}</property>

                 </bean>

              • 4. Re: HornetQ Server with dynamic IP-Address
                abc def Newbie

                When I change the JNDI-host to localhost or 0.0.0.0, then the whole server becomes invisible from the outside.

                 

                This is the error in the client after changing to localhost/0.0.0.0 at JNDI and to 0.0.0.0 at HornetQ:

                 

                In case of localhost at JNDI:

                "Could not obtain connection to any of these urls: XXX.YYY.ZZ.WWW:1099" and discovery failed with error: javax.naming.CommnicationException....[recievied timed out]

                 

                In case of 0.0.0.0 at JNDI:

                Like before: Connection refused

                • 5. Re: HornetQ Server with dynamic IP-Address
                  Clebert Suconic Master

                  I just changed this on my local copy and it worked:

                   

                     <!-- JNDI server. Disable this if you don't want JNDI -->

                     <bean name="JNDIServer" class="org.jnp.server.Main">

                        <property name="namingInfo">

                           <inject bean="Naming"/>

                        </property>

                        <property name="port">1099</property>

                        <property name="bindAddress">0.0.0.0</property>

                        <property name="rmiPort">1098</property>

                        <property name="rmiBindAddress">0.0.0.0</property>

                     </bean>

                   

                   

                  Also, change all the acceptors.

                   

                  On the connectors though.. you will have to define an IP. (maybe you should directly instantiate the connection factories).

                  • 6. Re: HornetQ Server with dynamic IP-Address
                    abc def Newbie

                    I have run more tests today.

                     

                    Your solution with 0.0.0.0 as address only works if you connect from the same machine.

                     

                    From other machines in the network I get exceptions:

                     

                    0.0.0.0 in the JNDI config results in a "connection refused" exception.

                    0.0.0.0 in the connectors results in a timeout exception.

                    0.0.0.0 in the acceptors seem to work.

                    • 7. Re: HornetQ Server with dynamic IP-Address
                      jaikiran pai Master

                      abc def wrote:

                       

                      I have run more tests today.

                       

                      Your solution with 0.0.0.0 as address only works if you connect from the same machine.

                       

                      From other machines in the network I get exceptions:

                       

                      0.0.0.0 in the JNDI config results in a "connection refused" exception.

                      You haven't yet posted any real complete code which is doing the lookup. If you are doing the lookup by specifying the Context.PROVIDER_URL value as 0.0.0.0, then it's not going to work. The client, during lookup, is expected to specify the IP or the hostname. 0.0.0.0 on the client will not work.

                      • 8. Re: HornetQ Server with dynamic IP-Address
                        abc def Newbie

                        To overcome the problems I am using the service of dynDNS now. Works fine.