Automattic / mongoose

MongoDB object modeling designed to work in an asynchronous environment.
https://mongoosejs.com
MIT License
26.92k stars 3.84k forks source link

Getting error while connecting through replicaset db. #9363

Closed surajpra closed 3 years ago

surajpra commented 4 years ago

Do you want to request a feature or report a bug? bug What is the current behavior? Getting error while connecting through replicaset db.

TopologyDescription {
  type: 'ReplicaSetNoPrimary',
  setName: null,
  maxSetVersion: null,
  maxElectionId: null,
  servers: Map {
    'cluster0-shard-00-01.cts4x.mongodb.net:27017' => ServerDescription {
      address: 'cluster0-shard-00-01.cts4x.mongodb.net:27017',
      error: undefined,
      roundTripTime: -1,
      lastUpdateTime: 168210740,
      lastWriteDate: null,
      opTime: null,
      type: 'Unknown',
      minWireVersion: 0,
      maxWireVersion: 0,
      hosts: [],
      passives: [],
      arbiters: [],
      tags: []
    },
    'cluster0-shard-00-00.cts4x.mongodb.net:27017' => ServerDescription {
      address: 'cluster0-shard-00-00.cts4x.mongodb.net:27017',
      error: undefined,
      roundTripTime: -1,
      lastUpdateTime: 168210740,
      lastWriteDate: null,
      opTime: null,
      type: 'Unknown',
      minWireVersion: 0,
      maxWireVersion: 0,
      hosts: [],
      passives: [],
      arbiters: [],
      tags: []
    },
    'cluster0-shard-00-02.cts4x.mongodb.net:27017' => ServerDescription {
      address: 'cluster0-shard-00-02.cts4x.mongodb.net:27017',
      error: undefined,
      roundTripTime: -1,
      lastUpdateTime: 168210740,
      lastWriteDate: null,
      opTime: null,
      type: 'Unknown',
      minWireVersion: 0,
      maxWireVersion: 0,
      hosts: [],
      passives: [],
      arbiters: [],
      tags: []
    }
  },
  stale: false,
  compatible: true,
  compatibilityError: null,
  logicalSessionTimeoutMinutes: null,
  heartbeatFrequencyMS: 10000,
  localThresholdMS: 15,
  commonWireVersion: null
}

If the current behavior is a bug, please provide the steps to reproduce. connection uri : mongodb+srv://superman:***@cluster0.cts4x.mongodb.net/ultimate-db?authSource=admin&replicaSet=atlas-99t0pg-shard-0&readPreference=primary

What is the expected behavior? Perfect Connection What are the versions of Node.js, Mongoose and MongoDB you are using? Note that "latest" is not a version. Node.js: 12.18.3 Mongoose: 5.10.1 MongoDB : 4.2.8 Enterprise

vkarpov15 commented 4 years ago

What is the actual error? TopologyDescription is often a property of connection errors, but not the actual error message itself.

Based on the topology state, it might be that your IP is not in the IP whitelist for this Atlas cluster. Can you please double check that you can connect using the mongo shell or Compass?