Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to solve MongoError: pool destroyed while connecting to CosmosDB

I have Node.js service in which I am using mongo-API to communicate with Document/Cosmos DB. My service run's fine and performs all the crud operation but after 1 min some mongo error throws from the service.

/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)

I am not able to understand why this error is coming up.Please suggest the changes that need to be done to resolve this error.

like image 308
Anand Deshmukh Avatar asked May 22 '17 15:05

Anand Deshmukh


1 Answers

I run into the same problem, removed the replica set parameter in the connection string mongodb: ........./?ssl=true**&replicaSet=globaldb** then it worked fine

like image 124
MD8515 Avatar answered Oct 26 '22 01:10

MD8515