-
Type: Bug
-
Resolution: Done
-
Priority: 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