[JAVA-2245] MongoClient Instantiation Using IPV6 Address Causes "com.mongodb.MongoException: host and port should be specified in host:port format" Created: 14/Jul/16  Updated: 19/Oct/16  Resolved: 14/Jul/16

Status: Closed
Project: Java Driver
Component/s: Connection Management
Affects Version/s: 3.2.2
Fix Version/s: 3.3.0

Type: Bug Priority: Major - P3
Reporter: Ibrahim Ahmed Assignee: Justin Lee
Resolution: Done Votes: 0
Labels: ipv6
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Mac OS X 10.11.5, Java 7


Issue Links:
Related
related to JAVA-2220 Calls to new ServerAddress(InetAddres... Closed

 Description   

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)



 Comments   
Comment by Ibrahim Ahmed [ 15/Jul/16 ]

Jeff,

2016-07-15 09:33:08.714 [main] DEBUGtestrunner.TestRunner - com.mongo.mongodb.util.MongoDBClient$Companion: Created MongoClient with server addresses <[[2604:fe00:3:1109:250:56ff:fe87:6500]:27017]>

Looks good. Thanks Mongo team.

Comment by Jeffrey Yemin [ 15/Jul/16 ]

There is a SNAPSHOT available on Sonatype containing this fix. Care to give it a try, atbe?

Comment by Ibrahim Ahmed [ 14/Jul/16 ]

PS.
Thank you Justin for programming the solution so quickly and following up with me on irc.

Comment by Ibrahim Ahmed [ 14/Jul/16 ]

Hey Jeff,

Thanks for fixing it. Looking forward to the next release.

Comment by Jeffrey Yemin [ 14/Jul/16 ]

Hi Ibrahim,

This is a bug, so thanks for bringing it too our attention. We have a fix in code review and will try to get it in to the next release.

Comment by Ibrahim Ahmed [ 14/Jul/16 ]

More descriptive version of issue: http://stackoverflow.com/questions/38375308/mongoclient-instantiation-using-ipv6-address-throws-mongoexception-host-and-po

Generated at Thu Feb 08 08:56:42 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.