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

MongoClient Instantiation Using IPV6 Address Causes "com.mongodb.MongoException: host and port should be specified in host:port format"

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.0
    • Affects Version/s: 3.2.2
    • Component/s: Connection Management
    • Environment:
      Mac OS X 10.11.5, Java 7

      Hello,

      When running the below code snippet, a MongoException is thrown.

      final String host = "[2604:fe00:3:1103:250:56ff:fe98:c831]";

      ServerAddress address = new ServerAddress(host, 27017);
      System.out.println(address.getHost());

      MongoClient client = new MongoClient(host);

      This is a valid IPV6 address.

      Any help would be appreciated. I have tried many different ways of instantiating the client, they all fall back to the same process.

      • Make ServerAddress using host string.
      • Pass to MongoClient.
      • Attempt MongoClient Construction using address.
      • Exception thrown.

      The exception is:

      com.mongodb.MongoException: host and port should be specified in host:port format
      
      at com.mongodb.ServerAddress.<init>(ServerAddress.java:122)
      at com.mongodb.connection.ClusterSettings$Builder.hosts(ClusterSettings.java:102)
      at com.mongodb.Mongo.createCluster(Mongo.java:670)
      at com.mongodb.Mongo.<init>(Mongo.java:281)
      at com.mongodb.Mongo.<init>(Mongo.java:277)
      at com.mongodb.MongoClient.<init>(MongoClient.java:174)
      at com.mongodb.MongoClient.<init>(MongoClient.java:151)
      at com.mongodb.MongoClient.<init>(MongoClient.java:121)
      

            Assignee:
            justin.lee Justin Lee
            Reporter:
            atbe Ibrahim Ahmed
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: