Details
-
Bug
-
Resolution: Won't Fix
-
Major - P3
-
None
-
None
-
None
Description
If you pass in a list of servers, one must be master. If you just want to connect to a slave, do "new Mongo(new ServerAddress(ip))".
On Tue, Sep 7, 2010 at 10:46 AM, Joseph Wang <josephykwang@yahoo.com> wrote:
String[] servers = server_list.split(",");
ArrayList<ServerAddress> addr = new ArrayList<ServerAddress>();
int serverCount = 0;
for (int i = 0; i < servers.length; ++i) {
String[] serverInfo = servers[i].split(":");
try {
if (serverInfo.length == SERVER_INFORMATION_FIELD_SIZE)
} catch (Exception ex) {
}
}
if (serverCount > 0)
{ m = new Mongo(addr, opt); } From: Kristina Chodorow <kristina@10gen.com>
To: mongodb-user@googlegroups.com
Sent: Tue, September 7, 2010 7:16:19 AM
Subject: Re: [mongodb-user] Java Driver Failed to Connect to Slaves
What does your code look like? Are you calling "new Mongo(ip1, ip2)"? If you're connecting to a slave, you should just say "new Mongo(ip1)".
On Tue, Sep 7, 2010 at 1:01 AM, Joseph Wang <josephykwang@yahoo.com> wrote:
MongoConnnection: add server ip-10-160-86-4 at port 10000
MongoConnnection: add server ip-10-161-50-230 at port 10000
...
SEVERE: switched to: ip-10-160-86-4:10000 but isn't master
Sep 7, 2010 12:58:04 AM com.mongodb.DBTCPConnector _pickInitial
SEVERE: can't pick initial master, using random one
com.mongodb.MongoException: can't find master
at com.mongodb.DBTCPConnector._pickInitial(DBTCPConnector.java:422)
at com.mongodb.Mongo.<init>(Mongo.java:177)