【发布时间】:2020-08-19 23:50:16
【问题描述】:
因为我真的不知道问题可能是什么,所以我只是复制粘贴错误。我搜索了谷歌,但到目前为止没有成功。代码的第一部分是我猜的问题,所以我只是添加了第二部分以防它可能更有帮助。基本上,几天后,我的数据库停止工作,我不知道为什么。这是 MongoDB 的云版本,我使用 NodeJs + ExpressJs + Mongoose。提前感谢您的每一个提示。
0|app | at eachAsync (/home/redicerap/apps/nashinobi/backend/node_mod ules/mongodb/lib/core/utils.js:135:5)
0|app | at Pool.reset (/home/redicerap/apps/nashinobi/backend/node_mo dules/mongodb/lib/core/connection/pool.js:709:3)
0|app | at /home/redicerap/apps/nashinobi/backend/node_modules/mongod b/lib/core/sdam/monitoring.js:202:19
0|app | at /home/redicerap/apps/nashinobi/backend/node_modules/mongod b/lib/core/sdam/monitoring.js:164:18
0|app | at Server.command (/home/redicerap/apps/nashinobi/backend/nod e_modules/mongodb/lib/core/sdam/server.js:239:14)
0|app | at checkServer (/home/redicerap/apps/nashinobi/backend/node_m odules/mongodb/lib/core/sdam/monitoring.js:148:12)
0|app | at Object.monitorServer [as monitorFunction] (/home/redicerap /apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/monitoring.js:193:3)
0|app | at Server.monitor (/home/redicerap/apps/nashinobi/backend/nod e_modules/mongodb/lib/core/sdam/server.js:216:12)
0|app | at Timeout.<anonymous> (/home/redicerap/apps/nashinobi/backen d/node_modules/mongodb/lib/core/sdam/topology.js:859:22)
0|app | at listOnTimeout (internal/timers.js:531:17) {
0|app | name: 'MongoError',
0|app | [Symbol(mongoErrorContextSymbol)]: {}
0|app | },
0|app | [Symbol(mongoErrorContextSymbol)]: {}
0|app | }
0|app | MongoTimeoutError: Server selection timed out after 30000 ms
0|app | at Timeout._onTimeout (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/topology.js:878:9)
0|app | at listOnTimeout (internal/timers.js:531:17)
0|app | at processTimers (internal/timers.js:475:7) {
0|app | name: 'MongoTimeoutError',
0|app | reason: MongoError: server instance pool was destroyed
0|app | at basicWriteValidations (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/server.js:408:12)
0|app | at basicReadValidations (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/server.js:415:17)
0|app | at Server.command (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/server.js:237:19)
0|app | at checkServer (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/monitoring.js:148:12)
0|app | at /home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/monitoring.js:204:7
0|app | at /home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/connection/pool.js:732:9
0|app | at eachAsync (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/utils.js:135:5)
0|app | at Pool.reset (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/connection/pool.js:709:3)
0|app | at /home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/monitoring.js:202:19
0|app | at /home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/monitoring.js:164:18
0|app | at Server.command (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/server.js:239:14)
0|app | at checkServer (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/monitoring.js:148:12)
0|app | at Object.monitorServer [as monitorFunction] (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/monitoring.js:193:3)
0|app | at Server.monitor (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/server.js:216:12)
0|app | at Timeout.<anonymous> (/home/redicerap/apps/nashinobi/backend/node_modules/mongodb/lib/core/sdam/topology.js:859:22)
0|app | at listOnTimeout (internal/timers.js:531:17) {
0|app | name: 'MongoError',
0|app | [Symbol(mongoErrorContextSymbol)]: {}
0|app | },
0|app | [Symbol(mongoErrorContextSymbol)]: {}
0|app | }
【问题讨论】:
-
检查 mongo.close() stackoverflow.com/questions/49429462/…
-
@Girgetto 我已经在这个线程中寻找了解决方案。我没有 mongo 关闭。我只是建立一个连接,就是这样。
-
@AlexG。这个问题的任何解决方案?我对 mongodb 4.0.1 也有同样的问题
-
@NimeshaKalinga 对于这么晚的回复,我深表歉意,但解决方案非常简单。我在 2 个不同的地方返回了响应,因为我不喜欢 mongo 查询的嵌套。所以整个后端因此而崩溃,但很难发现,因为它很少发生,但经常发生。确保返回 res.status(200) 或任何一次,我错误地认为在触发第一次返回后根本不会达到第二次返回。
-
@AlexG。嗨,亚历克斯,就我而言,这与服务器上的 Windows 更新和 mongodb 版本有关。将mongodb更新到最新,问题就消失了。
标签: node.js mongodb express mongoose