Uploaded image for project: 'Java Driver'
  1. Java Driver
  2. JAVA-829

When using a different port for a localhost, the driver is defaulting back to port 27017 when GMongo is built with ServerAddress objects

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.10.1
    • Component/s: Connection Management
    • Labels:
      None
    • Environment:
      Windows 7, Java 7

      When connecting to a port other than 27017 on localhost, the GMongo driver will not work and default back to 27017 if using an array of ServerAddress objects. See code below. The last println prints the same as the second. It should print the same as the first.

      @Grab(group='org.mongodb', module='mongo-java-driver', version='2.10.1')

      import com.mongodb.*

      //tunnels to another mongo instance
      def mongo = new Mongo("localhost",29017)
      println "${mongo.getDatabaseNames()}"

      //my actual local
      mongo = new Mongo("localhost",27017)
      println "${mongo.getDatabaseNames()}"

      //BUG - try to do connect to remote cluster (29017 is the same as connected to above)
      mongo = new Mongo([new ServerAddress("localhost",29017), new ServerAddress("localhost",29018), new ServerAddress("localhost",29018)])
      println "${mongo.getDatabaseNames()}"
      //result is that this connects to 27017 on localhost instead of the other server addresses

        1. TestMongo.java
          0.8 kB
        2. TestMongo.java
          0.9 kB
        3. test-output.txt
          3 kB

            Assignee:
            Unassigned Unassigned
            Reporter:
            sdr984 Scott Roberts
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: