{ MongoNetworkError: connection 3 to cluster0-shard-00-02-z0urk.mongodb.net:27017 在 TLSSocket 关闭。(/home/fahad/Personal Work/Nodejs/Node js start/node_modules/mongoose/node_modules/mongodb-core/lib/connection/connection.js:352:9) 在 Object.onceWrapper (events.js:276:13)在 TLSSocket.emit (events.js:188:13) at _handle.close (net.js:610:12) at TCP.done (_tls_wrap.js:386:7) name: 'MongoNetworkError', errorLabels: [ 'TransientTransactionError ' ],
[Symbol(mongoErrorContextSymbol)]: {} }
module.exports = (app, express , mongoose, path, bodyParser) => {
app.use(express.static(path.resolve(__dirname, "../../dist")));
app.use(bodyParser.json());
mongoose.connect('mongodb+srv://fahad:123@cluster0-z0urk.mongodb.net/test?retryWrites=true', {useNewUrlParser: true})
.then(()=>console.log("DB server connect"))
.catch(e => console.log("DB error", e));
};
Run Code Online (Sandbox Code Playgroud)