-
Type: Bug
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: Connection Management
-
None
-
Environment:Mac OS X
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04-307-9M3263)
Java HotSpot(TM) 64-Bit Server VM (build 17.1-b03-307, mixed mode)
Our application runs on machines that are sometimes moved between networks or has its IP address changed.
When we create the Mongo instance it is done using the "localhost" host for the Mongo server. The Mongo driver appears to always resolve to an IP on the local subnet. "192.168.0.10" for example. When the network chances however, our applications starts failing with errors like the following because it can no longer connect:
jvm 1 | java.io.IOException: couldn't connect to [io/192.168.0.10:27017] bc:java.net.ConnectException: Operation timed out
jvm 1 | at com.mongodb.DBPort._open(DBPort.java:205)
jvm 1 | at com.mongodb.DBPort.go(DBPort.java:94)
jvm 1 | at com.mongodb.DBPort.go(DBPort.java:75)
jvm 1 | at com.mongodb.DBPort.call(DBPort.java:65)
jvm 1 | at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:215)
jvm 1 | at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:295)
jvm 1 | at com.mongodb.DBCursor._check(DBCursor.java:354)
jvm 1 | at com.mongodb.DBCursor._hasNext(DBCursor.java:484)
jvm 1 | at com.mongodb.DBCursor.hasNext(DBCursor.java:509)
jvm 1 | at com.mongodb.jdbc.MongoResultSet.next(MongoResultSet.java:640)
...
I have configured the Mongo instance to automatically try to reconnect, but the conversion from "localhost" to "192.168.0.10" only happens once. The only way to get Mongo to reconnect is to restart the Java instance.
I assume that there is a reason why the IP is being resolved, but would it be possible to make the driver re-resolve the IP when doing a reconnect?
Thanks in advance,
Leif
- is duplicated by
-
JAVA-707 Refresh the IP resolved for hosts frequently enough to pick up dns changes for direct and mongos connections
- Closed
-
JAVA-1582 MongoClient constructor throws exception if one of the seed endpoints in MongoURI is not resolved by DNS
- Closed
- is related to
-
JAVA-249 Java Driver cannot connect to 'localhost' when mongod is listening only on 127.0.0.1 (or "localhost")
- Closed
-
JAVA-1582 MongoClient constructor throws exception if one of the seed endpoints in MongoURI is not resolved by DNS
- Closed
- related to
-
CSHARP-869 Stop Caching the IPEndPoint for a Server Instance.
- Closed