Fighting the same problem. Any input on this?

MongoClientOptions.Builder options = MongoClientOptions.builder(); options.socketKeepAlive(true).maxWaitTime(100).connectTimeout(100); MongoClient mongo = new MongoClient(host, options.build()); 

I get this because the pool is closed, but I do not want the pool to be closed since my application. I want the pool to continue until the end of the application or at least one specific class. Any help would be appreciated.

 Closed connection [connectionId{localValue:124, serverValue:8540}] to localhost:27017 because the pool has been closed. 
+6
source share
1 answer

MongoDB provides several connection pool options to test this. Mongo Connection Pool Settings

MaxPoolSize The maximum number of connections in the connection pool. The default value is 100.

minPoolSize The minimum number of connections in the connection pool. The default value is 0.

maxIdleTimeMS The maximum number of milliseconds that a connection can remain idle in the pool before being deleted and closed.

This option is not supported by all drivers.

waitQueueMultiple The number at which the driver multiplies the value of maxPoolSize by to provide the maximum number of threads that are allowed to wait for the connection to be available from the pool. For default values, see the MongoDB Driver and Client Library File Documentation.

waitQueueTimeoutMS The maximum time in milliseconds that a thread can wait for a connection to become available. For default values, see the MongoDB Driver and Client Library File Documentation.

0
source

Source: https://habr.com/ru/post/1013438/


All Articles