如何解决MongoError:连接到CosmosDB时池被破坏

Ana*_*ukh 11 mongodb node.js npm azure-cosmosdb

我有Node.js服务,其中我使用mongo-API与Document/Cosmos DB进行通信.我的服务运行正常,并执行所有的crud操作,但1分钟后,一些mongo错误从服务中抛出.

/document-db-service/node_modules/mongodb/lib/utils.js:123
    process.nextTick(function() { throw err; });
                                  ^
MongoError: pool destroyed
    at Pool.write (/document-db-service/node_modules/mongodb-core/lib/connection/pool.js:922:12)
    at Cursor._find (/document-db-service/node_modules/mongodb-core/lib/cursor.js:286:22)
    at nextFunction (/document-db-service/node_modules/mongodb-core/lib/cursor.js:584:10)
    at Cursor.next [as _next] (/document-db-service/node_modules/mongodb-core/lib/cursor.js:692:3)
    at fetchDocs (/document-db-service/node_modules/mongodb/lib/cursor.js:856:10)
    at toArray (/document-db-service/node_modules/mongodb/lib/cursor.js:883:3)
    at Cursor.toArray (/document-db-service/node_modules/mongodb/lib/cursor.js:836:44)
    at exports.getDocsOfCollections (/document-db-service/services/collections.js:273:10)
    at Layer.handle [as handle_request] (/document-db-service/node_modules/express/lib/router/layer.js:95:5)
    at next (/document-db-service/node_modules/express/lib/router/route.js:137:13)
Run Code Online (Sandbox Code Playgroud)

我无法理解为什么会出现此错误.请建议需要进行的更改以解决此错误.

小智 6

我遇到了同样的问题,删除了连接字符串mongodb中的副本集参数: ........./?ssl=true**&replicaSet=globaldb** 然后它工作正常

  • 如果有人解释了为什么会起作用,那就太好了:| (2认同)