I am using AWS DocumentDB as my database in my application which is developed in node.js which is MongoDB compatible. I have used MongoClient to connect to my database. My application executes but it makes approx 1000 DB connections for each execution and then it fails with an error:
MongoServerSelectionError: connection <monitor> to xxx.xx.xx.xxx:27017 closed.
I tried to use client.close()
as well to close the connections then it gave that the connection pool is closed. I believe that issue is due to so many database connections.
How can I release the connections in MongoDB? Any help is appreciated.