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

        Hide
        Byron Nevins added a comment -

        We have so many possible combinations and installations of networking. The current code is the result of years of testing and tweaking.

        It is too dangerous to change this area of code for a very very rare situation.

        Final solution: Don't do that!

        Show
        Byron Nevins added a comment - We have so many possible combinations and installations of networking. The current code is the result of years of testing and tweaking. It is too dangerous to change this area of code for a very very rare situation. Final solution: Don't do that!
        Hide
        Ryan Lubke added a comment -

        Unfortunately, I don't have easy access to a win32 environment so I can't tell you how to alias the IP.

        The steps outside of the ip aliasing are there in the bug report.

        Show
        Ryan Lubke added a comment - Unfortunately, I don't have easy access to a win32 environment so I can't tell you how to alias the IP. The steps outside of the ip aliasing are there in the bug report.
        Hide
        Byron Nevins added a comment -

        Setting target to 3.2

        RYAN –

        Can you give me a simple way to reproduce this on my windows machine – i.e. step-by-step cookbook?

        Show
        Byron Nevins added a comment - Setting target to 3.2 RYAN – Can you give me a simple way to reproduce this on my windows machine – i.e. step-by-step cookbook?

          People

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

            Dates

            • Created:
              Updated:
              Resolved: