TBE*_*TBE 16 mongoose node.js node-mongodb-native
设置后useUnifiedTopology=true,自动重新连接停止工作并生成以下错误:
DeprecationWarning: The option `reconnectInterval` is incompatible with the unified topology
DeprecationWarning: The option `reconnectTries` is incompatible with the unified topology
DeprecationWarning: The option `autoReconnect` is incompatible with the unified topology
Run Code Online (Sandbox Code Playgroud)
我怎样才能让服务器自动重新连接那个新标志?
我正在使用mongoose.createConnection以下选项进行连接:
{
autoReconnect: true,
keepAliveInitialDelay: 300000,
connectTimeoutMS: 300000,
reconnectTries: Number.MAX_VALUE,
reconnectInterval: 1000,
useNewUrlParser: true,
useUnifiedTopology: true,
useCreateIndex: true,
poolSize: 10,
auth: {
authSource: "admin"
},
user: process.env.MONGO_USER,
pass: process.env.MONGO_PASS
}
Run Code Online (Sandbox Code Playgroud)
根据文档,您通常不应autoReconnect与useUnifiedTopologySource结合设置:https : //mongoosejs.com/docs/connections.html#options
autoReconnect - 底层 MongoDB 驱动程序将在失去与 MongoDB 的连接时自动尝试重新连接。除非您是想要管理自己的连接池的非常高级的用户,否则不要将此选项设置为 false。
| 归档时间: |
|
| 查看次数: |
5904 次 |
| 最近记录: |