-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.1.13
-
Component/s: None
-
(copied to CRM)
-
Empty show more show less
this code works fine when useNewUrlParser === false
const MongoClient = require('mongodb').MongoClient
const fs = require('fs')
const mongoUrl = "mongodb://cortex-mongo-0.cortex-mongo.default,cortex-mongo-1.cortex-mongo.default,cortex-mongo-2.cortex-mongo.default/AnalyticsUi?ssl=true&authMechanism=MONGODB-X509&replicaSet=rs0"
const mongoOpts = {
"cert": "keys/mongo-client.pem",
"key": "keys/mongo-client.pem",
"ca": "keys/ca.crt"
}
const ROOT_PATH = process.cwd()
const options = {
sslKey: fs.readFileSync(ROOT_PATH + '/' + mongoOpts['key']),
sslCert: fs.readFileSync(ROOT_PATH + '/' + mongoOpts['cert']),
sslCA: fs.readFileSync(ROOT_PATH + '/' + mongoOpts['ca']),
useNewUrlParser: true
}
MongoClient.connect(mongoUrl, options, async (...args) => {
const [err, client] = args
if (err) console.error({err})
if (client) {
const db = client.db()
const data = await db.collection('tasks').find({}).toArray()
console.log('data', data)
{{ }}}
})
But it throws the error "MongoError: command find requires authentication" if useNewUrlParser == true{{}}
- is related to
-
NODE-1901 After 2-3 weeks of running fine getting error: like command find/insert/edit/delete requires authentication, although all config was set properly
- Closed