How to properly close a connection? (But not the driver)

421 views
Skip to first unread message

Kaizah Kaiser

unread,
Aug 2, 2016, 9:49:02 AM8/2/16
to ReactiveMongo - http://reactivemongo.org
I am trying to simply close a connection but keep the driver intact (because I want to reuse it to connect again later to a different replica set). Doing so gives me all sorts of dead letters.

What I am doing:
val driver = new MongoDriver()
val conn = driver.connection
val conn = driver.connection(List("localhost"))
conn.close

But when the connection is closed, I get all these (limited to 10):

[INFO] [08/02/2016 15:45:42.233] [reactivemongo-akka.actor.default-dispatcher-2] [akka://reactivemongo/deadLetters] Message [reactivemongo.core.actors.Closed$] from Actor[ak
ka://reactivemongo/user/Monitor-Connection-2#-435832937] to Actor[akka://reactivemongo/deadLetters] was not delivered. [1] dead letters encountered. This logging can be turned off
or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [08/02/2016 15:45:42.233] [reactivemongo-akka.actor.default-dispatcher-2] [akka://reactivemongo/user/Connection-2] Message [reactivemongo.core.actors.ChannelDisconnected] fr
om Actor[akka://reactivemongo/deadLetters] to Actor[akka://reactivemongo/user/Connection-2#-1358334014] was not delivered. [2] dead letters encountered. This logging can be turned
off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [08/02/2016 15:45:42.233] [reactivemongo-akka.actor.default-dispatcher-2] [akka://reactivemongo/user/Connection-2] Message [reactivemongo.core.actors.ChannelClosed] from Act
or[akka://reactivemongo/deadLetters] to Actor[akka://reactivemongo/user/Connection-2#-1358334014] was not delivered. [3] dead letters encountered. This logging can be turned off or
 adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [08/02/2016 15:45:42.233] [reactivemongo-akka.actor.default-dispatcher-2] [akka://reactivemongo/user/Connection-2] Message [reactivemongo.core.actors.ChannelDisconnected] fr
om Actor[akka://reactivemongo/deadLetters] to Actor[akka://reactivemongo/user/Connection-2#-1358334014] was not delivered. [4] dead letters encountered. This logging can be turned
off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [08/02/2016 15:45:42.233] [reactivemongo-akka.actor.default-dispatcher-2] [akka://reactivemongo/user/Connection-2] Message [reactivemongo.core.actors.ChannelClosed] from Act
or[akka://reactivemongo/deadLetters] to Actor[akka://reactivemongo/user/Connection-2#-1358334014] was not delivered. [5] dead letters encountered. This logging can be turned off or
 adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [08/02/2016 15:45:42.234] [reactivemongo-akka.actor.default-dispatcher-2] [akka://reactivemongo/user/Connection-2] Message [reactivemongo.core.actors.ChannelDisconnected] fr
om Actor[akka://reactivemongo/deadLetters] to Actor[akka://reactivemongo/user/Connection-2#-1358334014] was not delivered. [6] dead letters encountered. This logging can be turned
off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [08/02/2016 15:45:42.234] [reactivemongo-akka.actor.default-dispatcher-2] [akka://reactivemongo/user/Connection-2] Message [reactivemongo.core.actors.ChannelClosed] from Act
or[akka://reactivemongo/deadLetters] to Actor[akka://reactivemongo/user/Connection-2#-1358334014] was not delivered. [7] dead letters encountered. This logging can be turned off or
 adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [08/02/2016 15:45:42.234] [reactivemongo-akka.actor.default-dispatcher-2] [akka://reactivemongo/user/Connection-2] Message [reactivemongo.core.actors.ChannelDisconnected] fr
om Actor[akka://reactivemongo/deadLetters] to Actor[akka://reactivemongo/user/Connection-2#-1358334014] was not delivered. [8] dead letters encountered. This logging can be turned
off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [08/02/2016 15:45:42.234] [reactivemongo-akka.actor.default-dispatcher-2] [akka://reactivemongo/user/Connection-2] Message [reactivemongo.core.actors.ChannelClosed] from Act
or[akka://reactivemongo/deadLetters] to Actor[akka://reactivemongo/user/Connection-2#-1358334014] was not delivered. [9] dead letters encountered. This logging can be turned off or
 adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.
[INFO] [08/02/2016 15:45:42.234] [reactivemongo-akka.actor.default-dispatcher-2] [akka://reactivemongo/user/Connection-2] Message [reactivemongo.core.actors.ChannelDisconnected] fr
om Actor[akka://reactivemongo/deadLetters] to Actor[akka://reactivemongo/user/Connection-2#-1358334014] was not delivered. [10] dead letters encountered, no more dead letters will
be logged. This logging can be turned off or adjusted with configuration settings 'akka.log-dead-letters' and 'akka.log-dead-letters-during-shutdown'.


Cédric Chantepie

unread,
Aug 2, 2016, 10:54:14 AM8/2/16
to ReactiveMongo - http://reactivemongo.org
Hi,

There is a misunderstanding. As indicated in the documentation, a MongoConnection stands for a logical connection, aka a pool of network channel.
So usually, there is only one instance (as for the MongoDriver) per application lifecycle.

Best regards

Kaizah Kaiser

unread,
Aug 3, 2016, 4:17:04 AM8/3/16
to ReactiveMongo - http://reactivemongo.org
No, there is no misunderstanding - I understand this perfectly well. In my scenario however (be it as it may), I do need to be able to close connections. I can elaborately explain why, but for the sake of simplicity I won't. I just want to know how (and maybe IF) it is possible to do a proper closing of just a (logical) connection (and hence it's underlying physical connections).

Op dinsdag 2 augustus 2016 16:54:14 UTC+2 schreef Cédric Chantepie:

Cédric Chantepie

unread,
Aug 3, 2016, 2:26:20 PM8/3/16
to ReactiveMongo - http://reactivemongo.org
If you think you need to close a specific pool, that's indeed MongoConnection.close, the logging being normal (INFO level) as the coming requests go to the dead letters since the closed pool refused to process it.
Reply all
Reply to author
Forward
0 new messages