glassfish
  1. glassfish
  2. GLASSFISH-16344

Unable to start two domains on system where IPs are aliased to the same network interface.

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Works as designed
    • Affects Version/s: 3.1
    • Fix Version/s: 4.0
    • Component/s: admin
    • Labels:
      None

      Description

      I'm trying to start two different domains on the same system, but have
      run into some issues that I hope you may be able to help with.

      Firstly, the machine I'm working with has a single NIC. The IP address
      is 10.0.1.100. I've created an IP alias to this NIC, 192.168.0.100.

      With a simple perl script, I'm able to bind the same port on either
      address (i.e. bind a server on 10.0.1.100:5000 and 192.168.0.100:5000).

      So, this confirms I have a basic working configuration.

      Now, I create a second domain, domain2, and update all the appropriate
      addresses to refer to 192.168.0.100. I update domain1 in a similar
      fashion and set the addresses to 10.0.1.100.

      I start domain1 using the following:

      asadmin --host 10.0.1.100 start-domain --verbose domain1

      I can see in the log that 10.0.1.100 is being used as expected.
      However, when I attempt to start domain2 using:

      asadmin --host 192.168.0.100 start-domain --verbose domain2

      I receive the following error:

      There is a process already using the admin port 4848 – it
      probably is another instance of a GlassFish server.

      I've looked through the code and came across this:

      private static boolean isPortFreeServer(int port) {
      // check 3 different ip-port combinations.
      // Amazingly I have seen all 3 possibilities – so just
      checking on 0.0.0.0
      // is not good enough.
      // Usually it is the 0.0.0.0 – but JMS (default:7676)
      // only returns false from the "localhost":port combination.
      // We want to be aggressively disqualifying ports rather than
      the other
      // way around

      try {
      byte[] allZero = new byte[]

      {0, 0, 0, 0}

      ;
      InetAddress add = InetAddress.getByAddress(allZero);

      if (isPortFreeServer(port, add) == false)
      return false; // return immediately on "not-free"

      add = InetAddress.getLocalHost();

      if (isPortFreeServer(port, add) == false)
      return false; // return immediately on "not-free"

      add = InetAddress.getByName("localhost");

      return isPortFreeServer(port, add);
      }
      catch (Exception e)

      { // If we can't get an IP address then we can't check return false; }

      }

      which is invoked by StartServerHelper to ensure the port isn't already
      bound.

      In my environment, the second isPortFreeServer() fails as
      InetAddress.getLocalHost() in this
      case returns 10.0.1.100. While this return value is correct, this
      appears to be a false positive.

      Wouldn't it make sense, in the case when an explicit host and/or port is passed to asadmin
      to perform the validation against those arguments instead of against the local addresses?

        Activity

        Ryan Lubke created issue -
        Nazrul made changes -
        Field Original Value New Value
        Component/s admin [ 10589 ]
        Byron Nevins made changes -
        Fix Version/s 3.2 [ 10969 ]
        Fix Version/s 3.1.1 [ 14740 ]
        Tags 3_1_1-exclude
        Byron Nevins made changes -
        Tags 3_1_1-exclude 3_1_1-exclude 3_1_1-scrubbed
        Byron Nevins made changes -
        Tags 3_1_1-exclude 3_1_1-scrubbed 3_1-next 3_1_1-exclude 3_1_1-scrubbed
        Byron Nevins made changes -
        Tags 3_1-next 3_1_1-exclude 3_1_1-scrubbed 3_1_x-exclude 3_1_1-exclude 3_1_1-scrubbed
        Jill Sato made changes -
        Fix Version/s 4.0 [ 10970 ]
        Fix Version/s 3.2 [ 10969 ]
        Byron Nevins made changes -
        Status Open [ 1 ] Closed [ 6 ]
        Resolution Works as designed [ 7 ]

          People

          • Assignee:
            Byron Nevins
            Reporter:
            Ryan Lubke
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved: