locked
node.js db connection RRS feed

  • Question

  • User2096382003 posted

    im new to node.js and am trying to connect to a mongodb database/collection.

    following the info here:

    https://www.mongodb.com/blog/post/quick-start-nodejs-mongodb--how-to-get-connected-to-your-database

    i get this error:-

    (node:19164) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.

    when i add { useUnifiedTopology: true } to the constructor i then get this error:-

    MongoServerSelectionError: connection <monitor> to 63.33.132.230:27017 closed
    at Timeout._onTimeout (C:\Projects\NodeJs\node_modules\mongodb\lib\core\sdam\topology.js:430:30)
    at listOnTimeout (internal/timers.js:549:17)
    at processTimers (internal/timers.js:492:7) {
    reason: TopologyDescription {
    type: 'ReplicaSetNoPrimary',
    setName: null,
    maxSetVersion: null,
    maxElectionId: null,
    servers: Map {
    'cluster0-shard-00-00-kjy43.mongodb.net:27017' => [ServerDescription],
    'cluster0-shard-00-01-kjy43.mongodb.net:27017' => [ServerDescription],
    'cluster0-shard-00-02-kjy43.mongodb.net:27017' => [ServerDescription]
    },
    stale: false,
    compatible: true,
    compatibilityError: null,
    logicalSessionTimeoutMinutes: null,
    heartbeatFrequencyMS: 10000,
    localThresholdMS: 15,
    commonWireVersion: null
    }
    }

    does anyone know what this is referring to?

    the example im trying to run from the mongo db website should just display a list of databases in my cluster...

    Monday, June 29, 2020 8:59 AM

All replies

  • User348806598 posted

    Hi,

    Check your mongodb server version and also the node client module that you are using. There may be node nodule version compatibility issues. 

    Wednesday, July 1, 2020 9:58 AM
  • User-18548748 posted

    For me, the app appears to connect at first, but after about 30 seconds I receive the exact same error message - eg. topology.js:430:30

    MongoDB 4.2.6 Community
    node v14.4.0

    packages:
    "express": "^4.17.1",
    "mongodb": "^3.5.9",
    "mongoose": "^5.9.20",

    Friday, July 3, 2020 6:52 PM