Geronimo
  1. Geronimo
  2. GERONIMO-4404

ActiveMQ connectors default to 0.0.0.0 when ServerHostname is set to localhost or actual IP.

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.3
    • Fix Version/s: 2.1.4, 2.2
    • Component/s: ActiveMQ
    • Security Level: public (Regular issues)
    • Labels:
      None
    • Patch Info:
      Patch Available

      Description

      Ron Staerker reported that if you change ServerHostname in config-substitutions.properties from 0.0.0.0 to 127.0.0.1, the default ActiveMQ connectors on 61613 and 61616 will still bind to 0.0.0.0 instead of the new ServerHostname value. This seems to b caused by several pom.xml problems, where:
      <config-property-setting name="ServerUrl">tcp://$

      {PlanServerHostname}

      :$

      {PlanActiveMQPort}

      </config-property-setting>
      where PlanServerHostname is 0.0.0.0 and not in config-substitutions.properties
      <attribute name="host">#

      {ServerHostname}</attribute>
      is being substituted in at build time to be 0.0.0.0 instead of putting ${ServerHostname}

      in the plans.

      1. G4404_truck.patch
        2 kB
        Shawn Jiang
      2. G4404_branch21.patch
        2 kB
        Shawn Jiang

        Activity

        Hide
        Jarek Gawor added a comment -

        Resolving as AMQ-2094 was fixed (ActiveMQ connectors should bind to the right ip in trunk too now).

        Show
        Jarek Gawor added a comment - Resolving as AMQ-2094 was fixed (ActiveMQ connectors should bind to the right ip in trunk too now).
        Hide
        Jarek Gawor added a comment -

        This should be fixed for branches/2.1. I regenerated the custom activemq-core.jar with the AMQ-2094 patch (see revision 742256).

        Show
        Jarek Gawor added a comment - This should be fixed for branches/2.1. I regenerated the custom activemq-core.jar with the AMQ-2094 patch (see revision 742256).
        Hide
        Donald Woods added a comment -

        David, can you take a look at the AMQ-2094 issue that Shawn opened? Thanks.

        Show
        Donald Woods added a comment - David, can you take a look at the AMQ-2094 issue that Shawn opened? Thanks.
        Hide
        Shawn Jiang added a comment -

        I've created a ActiveMQ JIRA here: https://issues.apache.org/activemq/browse/AMQ-2094

        Show
        Shawn Jiang added a comment - I've created a ActiveMQ JIRA here: https://issues.apache.org/activemq/browse/AMQ-2094
        Hide
        Shawn Jiang added a comment -

        I updated the title to

        ActiveMQ connectors default to 0.0.0.0 when ServerHostname is set to localhost or actual IP.

        from

        ActiveMQ connectors default to 0.0.0.0 when ServerHostname is set to localhost.

        Because I found that when the ServerHostname was set to the actual IP of the machine. The ActiveMQ will still bind to 0.0.0.0.

        • ActiveMQ works only with localhost and 127.0.0.1
          • 61613 0.0.0.0 ActiveMQ Transport Connector
          • 61616 0.0.0.0 ActiveMQ Transport Connector
            GERONIMO-4404 fixed the localhost to 0.0.0.0 problem, but the real connector \
            creation code in activemq is: \
            "org.apache.activemq.transport.tcp.TcpTransportServer"
              
                  InetAddress addr = InetAddress.getByName(host);
            
                   try {
                       if (host.trim().equals("localhost") || \
            addr.equals(InetAddress.getLocalHost())) {  //#1 start the socket with 0.0.0.0
                        this.serverSocket = \
            serverSocketFactory.createServerSocket(bind.getPort(), backlog);  }
                       else {
                        //#2  start the socket with the ip spcified in addr.
                        this.serverSocket = \
            serverSocketFactory.createServerSocket(bind.getPort(), backlog, addr);  }
            

            Since if you config the real IP as a host setting, \
            addr.equals(InetAddress.getLocalHost()) will allways be true so that the #1 will be \
            used to start the socket with 0.0.0.0. I'm not sure if it's a bug of activemq, \
            there's nothing we can do from geronimo side for now to fix this.

        Show
        Shawn Jiang added a comment - I updated the title to ActiveMQ connectors default to 0.0.0.0 when ServerHostname is set to localhost or actual IP. from ActiveMQ connectors default to 0.0.0.0 when ServerHostname is set to localhost. Because I found that when the ServerHostname was set to the actual IP of the machine. The ActiveMQ will still bind to 0.0.0.0. ActiveMQ works only with localhost and 127.0.0.1 61613 0.0.0.0 ActiveMQ Transport Connector 61616 0.0.0.0 ActiveMQ Transport Connector GERONIMO-4404 fixed the localhost to 0.0.0.0 problem, but the real connector \ creation code in activemq is: \ "org.apache.activemq.transport.tcp.TcpTransportServer" InetAddress addr = InetAddress.getByName(host); try { if (host.trim().equals( "localhost" ) || \ addr.equals(InetAddress.getLocalHost())) { //#1 start the socket with 0.0.0.0 this .serverSocket = \ serverSocketFactory.createServerSocket(bind.getPort(), backlog); } else { //#2 start the socket with the ip spcified in addr. this .serverSocket = \ serverSocketFactory.createServerSocket(bind.getPort(), backlog, addr); } Since if you config the real IP as a host setting, \ addr.equals(InetAddress.getLocalHost()) will allways be true so that the #1 will be \ used to start the socket with 0.0.0.0. I'm not sure if it's a bug of activemq, \ there's nothing we can do from geronimo side for now to fix this.
        Hide
        Shawn Jiang added a comment -

        This defect happens again with trunk code.

        I found that the class patched were removed in the latest code and the unit testing were commented out.

        Show
        Shawn Jiang added a comment - This defect happens again with trunk code. I found that the class patched were removed in the latest code and the unit testing were commented out.
        Hide
        Donald Woods added a comment -

        Rev718350 in branches/2.1 (2.1.4-SNAPSHOT)
        Doesn't really apply to trunk, as we are moving to AMQ5 for the 2.2 release.

        Show
        Donald Woods added a comment - Rev718350 in branches/2.1 (2.1.4-SNAPSHOT) Doesn't really apply to trunk, as we are moving to AMQ5 for the 2.2 release.
        Hide
        Donald Woods added a comment -

        Fix really only applies to the 2.1 releases which use ActiveMQ 4.1.2.

        Show
        Donald Woods added a comment - Fix really only applies to the 2.1 releases which use ActiveMQ 4.1.2.
        Hide
        Shawn Jiang added a comment -

        This is the patch to 2.1 branch.

        Show
        Shawn Jiang added a comment - This is the patch to 2.1 branch.
        Hide
        Shawn Jiang added a comment -

        Since activemq means to be used as standalone server. it's reasonable to them to amplify localhost to 0.0.0.0 to make sure the activemq is reachable if the user set the host other than "127.0.0.1".

        If so , we can force the localhost to 127.0.0.1 in geronimo side as a workaround. This is the patch to truck code. Please review, thanks.

        Show
        Shawn Jiang added a comment - Since activemq means to be used as standalone server. it's reasonable to them to amplify localhost to 0.0.0.0 to make sure the activemq is reachable if the user set the host other than "127.0.0.1". If so , we can force the localhost to 127.0.0.1 in geronimo side as a workaround. This is the patch to truck code. Please review, thanks.
        Hide
        Shawn Jiang added a comment -

        Seems a activemq bug to me. Following logic is used to convert a address to a serverSocket in class TcpTransportServer of activeMQ 4.1.2:

        String host = bind.getHost();

        host = (host == null || host.length() == 0) ? "localhost" : host;

        InetAddress addr = InetAddress.getByName(host);

        if (host.trim().equals("localhost") || addr.equals(InetAddress.getLocalHost()))

        { this.serverSocket = serverSocketFactory.createServerSocket(bind.getPort(), backlog); }

        else

        { this.serverSocket = serverSocketFactory.createServerSocket(bind.getPort(), backlog, addr); }

        Geronimo pass a "localhost" as host to ActiveMQ. After the convertion above, it'll return a 0.0.0.0/0.0.0.0 as the listening address back. Not sure why does activemq have such a logic to convert "localhost" to 0.0.0.0.

        Show
        Shawn Jiang added a comment - Seems a activemq bug to me. Following logic is used to convert a address to a serverSocket in class TcpTransportServer of activeMQ 4.1.2: String host = bind.getHost(); host = (host == null || host.length() == 0) ? "localhost" : host; InetAddress addr = InetAddress.getByName(host); if (host.trim().equals("localhost") || addr.equals(InetAddress.getLocalHost())) { this.serverSocket = serverSocketFactory.createServerSocket(bind.getPort(), backlog); } else { this.serverSocket = serverSocketFactory.createServerSocket(bind.getPort(), backlog, addr); } Geronimo pass a "localhost" as host to ActiveMQ. After the convertion above, it'll return a 0.0.0.0/0.0.0.0 as the listening address back. Not sure why does activemq have such a logic to convert "localhost" to 0.0.0.0.

          People

          • Assignee:
            David Jencks
            Reporter:
            Donald Woods
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development