Posted Sun, 29 Jul 2018 10:57:12 +0200 in reply to Ivo
Am 20.07.2018 um 12:40 schrieb Ivo:
I'm using a ConnectionPool (more specifically a MongoClient) to connect to a server and after some use I wish to terminate the connection.
I've see that removing the ConnectionPool variable does not actually destroy the object and the connection stays open.
I don't want to end up manually freeing memory since I believe it will cause several problems. So how can I terminate the connection?
Thanks for any help.
ConnectionPool assumes that each connection manages their
connection state individually, most importantly that it ensures that the
connection stays open/gets reconnected. Similarly, closing a connection
would also need to happen through the connection itself.
In the case of
MongoClient, the code needs to be extended to enable
MongoConnection.disconnect() in some way, or to define a
closing logic within
MongoConnection itself, for example a timeout.
The connection object itself would then still stay alive, but all
associated resources would be freed until it is used again. At that
point it would automatically reconnect.
Do you have specific semantics in mind for closing the connection(s)?