I am using "play framework (2.6)" with "(play2-reactivemongo, 0.12.6-play26)", and sometimes when the play server is working reactivemongo faces the following error:
ERROR] from reactivemongo.api.Cursor in application-akka.actor.default-dispatcher-202 - fails to send request
reactivemongo.core.actors.Exceptions$ClosedException: MongoError['This MongoConnection is closed (Supervisor-1/Connection-2)']
Caused by: reactivemongo.core.actors.Exceptions$InternalState: null
at reactivemongo.Close(<time:1509058236955>)
def coleccion: Future[JSONCollection] = reactiveMongoApi.database.map(_.collection("sellers"));
def sellers(limite:Int):Future[Seq[Seller]] = {
val query = BSONDocument()
val selector = BSONDocument(
"seller" -> 0
)
coleccion.flatMap(
_.find(query, selector).cursor[Seller](ReadPreference.primary)
.collect[Seq](limite,Cursor.FailOnError[Seq[Seller]]())
)
}
To solve this, it is necessary to restart the play server, making it possible to return to normal queries
When this error occurs I can make other queries but in the query where the error occurs it is "blocked" under this error.
Note: The mongo server is a remote, with a latency of 90 - 100
Some one now what am i doing wrong?
A MongoConnection is a pool and should only be closed at app shutdown.
Cébric you are right, when this error occurs I shoutdown the server and that's when the cursors detect that mongo is already closed and throw the errors. (I didn't notice that I was causing the message)I think the problem comes from the cursor that tries to get an answer but it doesn't and doesn't return an answer. When I call this same query again, the system still waits for the previous cursor to finish, and this causes this query to be blocked, until I restart the system.