Mongo db connection timeout

By default, the default connection time is 10 seconds in the mongo java driver. I stopped my mongo instance in my local and at the same time, I am trying to connect mongo db from java.

I am currently getting a timeout after a 10000ms exception.

My question is: Is it possible to throw a connection timeout exception before the default timeout (10000ms)?

+3


source to share


1 answer


The connection timeout will work in such a way that it will wait for the specified time, in your case 10 seconds.

There is no time to exclude a connection timed out exception before the specified time.

Literature:



https://api.mongodb.org/java/2.6/com/mongodb/MongoOptions.html#connectTimeout

How do I configure the MongoDB Java MongoOptions driver for production use?

+2


source







All Articles