我正在尝试使用猫鼬连接到mongodb atlas数据库,这是我的代码。const options = {
useNewUrlParser: true,
useCreateIndex: true,
useFindAndModify: false,
autoIndex: false, // Don't build indexes
reconnectTries: Number.MAX_VALUE, // Never stop trying to reconnect
reconnectInterval: 500, // Reconnect every 500ms
poolSize: 10, // Maintain up to 10 socket connections
// If not connected, return errors immediately rather than waiting for reconnect
bufferMaxEntries: 0,
connectTimeoutMS: 10000, // Give up initial connection after 10 seconds
socketTimeoutMS: 45000, // Close sockets after 45 seconds of inactivity
family: 4 // Use IPv4, skip trying IPv6
};
mongoose.connect('mongodb://admin:admin12@singhcl-shard-00-00-fm15e.mongodb.net:27017,singhcl-shard-00-01-fm15e.mongodb.net:27017,singhcl-shard-00-02-fm15e.mongodb.net:27017/test?ssl=true&replicaSet=SinghCL-shard-0&authSource=admin&retryWrites=true',options)
app.use(morgan('dev'));
我收到以下错误。
Error while trying to connect