Getting com.mongodb.MongoException: can't find a master exception on AWS

XMLWordPrintableJSON

    • Type: Task
    • Resolution: Duplicate
    • Priority: Blocker - P1
    • None
    • Affects Version/s: 2.7.3
    • Component/s: Connection Management
    • Environment:
      Amazon web services
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      Hello, We are trying to deploy our app on AWS. We are running a replica set configuration with 2 data nodes and 1 arbiter. Same configuration works fine on local environment but throws following exception on AWS

      com.mongodb.MongoException: can't find a master
      com.mongodb.DBTCPConnector.checkMaster(DBTCPConnector.java:434)
      com.mongodb.DBTCPConnector.call(DBTCPConnector.java:209)
      com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:305)
      com.mongodb.DBCollection.findOne(DBCollection.java:647)
      com.mongodb.DBCollection.findOne(DBCollection.java:626)
      com.mongodb.DBApiLayer$MyCollection.createIndex(DBApiLayer.java:364)
      com.mongodb.DBCollection.createIndex(DBCollection.java:436)
      com.mongodb.DBCollection.ensureIndex(DBCollection.java:515)
      com.google.code.morphia.DatastoreImpl.ensureIndex(DatastoreImpl.java:245)
      com.google.code.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:310)
      com.google.code.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:279)
      com.google.code.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:340)
      com.google.code.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:333)
      com.intuit.spark.MongoConnectionManager.<init>(MongoConnectionManager.java:37)

      Here is the config of replia set
      PRIMARY> rs.config()
      {
      "_id" : "sparkReplicaSet",
      "version" : 5,
      "members" : [

      { "_id" : 0, "host" : "ip-10-46-223-117:27017" }

      ,

      { "_id" : 1, "host" : "ip-10-46-167-177.ec2.internal:27017" }

      ,

      { "_id" : 2, "host" : "domU-12-31-39-04-D6-95.compute-1.internal:27017", "arbiterOnly" : true }

      ]
      }

      I have installed mongo shell on the app server(TOMCAT) host and I am able to connect to PRIMARY via the shell, that rules out networking issue.

      The code which gets the connection string is as follows
      List<ServerAddress> addrs = getMongoAddress();
      m = new Mongo(addrs);
      morphia = new Morphia();

      addrs List is created using
      ec2-23-22-74-137.compute-1.amazonaws.com:27017
      ec2-23-23-87-249.compute-1.amazonaws.com:27017
      ec2-23-22-156-48.compute-1.amazonaws.com:27017

      What are we missing in all this? Same code works on 3 node replica set on local machine. Here is config from my local setup
      PRIMARY> rs.config()
      {
      "_id" : "sparkdb",
      "version" : 3,
      "members" : [

      { "_id" : 0, "host" : "MPKL09407ef8d.local:27017" }

      ,

      { "_id" : 1, "host" : "MPKL09407ef8d.local:27088" }

      ,

      { "_id" : 2, "host" : "MPKL09407ef8d.local:27098" }

      ]
      }

      Thanks
      Sankate

              Assignee:
              Unassigned
              Reporter:
              Sankate Sharma
              None
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Created:
                Updated:
                Resolved: