Reputation: 21
Old API, I can disconnect the mongodb server.
MongoClient client = new MongoClient(connectionString);
.
.
.
client.GetServer().Disconnect();
but New API, the GetServer() Expired. and async issue ... is need to disconnect mongodb server?
Upvotes: 2
Views: 4482
Reputation: 9533
You shouldn't disconnect from mongodb server, because connections are managed by connection pool.
Creating new authenticated connections to the database is expensive. So, instead of creating and destroying connections for each request to the database, you want to re-use existing connections as much as possible. This is where connection pooling comes in. http://blog.mongolab.com/2013/11/deep-dive-into-connection-pooling/
Upvotes: 4