com.mongodb.MongoException: can't find master

JIRA | Joseph Wang | 6 years ago
  1. 0

    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) { System.out.println("MongoConnnection: add server " + serverInfo[SERVER_NAME_FIELD] + " at port " + serverInfo[SERVER_PORT_FIELD]); ServerAddress host = new ServerAddress( serverInfo[SERVER_NAME_FIELD], Integer.parseInt(serverInfo[SERVER_PORT_FIELD])); addr.add(host); serverCount++; } } 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)

    JIRA | 6 years ago | Joseph Wang
    com.mongodb.MongoException: can't find master
  2. 0

    Master Master Replication - java driver problem

    Google Groups | 6 years ago | Cheenu
    com.mongodb.MongoException: can't find master
  3. 0

    [mongodb-user] db error [not master]

    Google Groups | 7 years ago | Zsombor
    com.mongodb.MongoException: can't find master
  4. Speed up your debug routine!

    Automated exception search integrated into your IDE

  5. 0

    Can't configure Java Client Driver timeout

    Google Groups | 5 years ago | Diogo Vernier
    uol.newsfeed.commons.exception.DBCollectionWrapperException: An error occurred while executing the query null in the collection feed

    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. com.mongodb.MongoException

      can't find master

      at com.mongodb.DBTCPConnector._pickInitial()
    2. MongoDB Java Driver
      Mongo.<init>
      1. com.mongodb.DBTCPConnector._pickInitial(DBTCPConnector.java:422)
      2. com.mongodb.Mongo.<init>(Mongo.java:177)
      2 frames