i'm facing some issue when trying to connect to mongodb using my nodejs app.
heres the code
const { MongoClient } = require("mongodb");
async function main() {
const uri =
"mongodb+srv://xxxx:[email protected]/xxxx?retryWrites=true&w=majority";
const client = new MongoClient(uri);
await client.connect();
await listDatabases(client);
try {
await client.connect();
await listDatabases(client);
} catch (e) {
console.error(e);
} finally {
await client.close();
}
}
main().catch(console.error);
and heres the Output:
Error: queryTxt ETIMEOUT xxxx.uj545.mongodb.net
at QueryReqWrap.onresolve [as oncomplete] (dns.js:203:19) {
errno: undefined,
code: 'ETIMEOUT',
syscall: 'queryTxt',
hostname: 'xxxx.uj545.mongodb.net'
}
But when I tried to do a test connection with Mongodb Compass, I got the same problem.
then I tried Mongodb Compass using Windows VPS from the Google Cloud Platform, and it worked,
then, where did it go wrong?
the device that I use is Macbook Air early 2015 with MacOs mojave
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…