3

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

Currently I am getting time out after 10000 ms exception .

My question is: Is it possible to get connection time out exception before the default time out(10000 ms) ?

Panneerselvam
  • 361
  • 4
  • 12
  • Uhm, huh? Do you want something else to call for a timeout? Or do you wish to set the connection timeout to something else? – Danielson Jul 29 '15 at 15:55

1 Answers1

2

Connection Time Out will function in a way that it will wait for the specified time, in your case 10 seconds.

No it is not possible to get the connection time out exception before the specified time.

References:

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

How to configure MongoDB Java driver MongoOptions for production use?

Community
  • 1
  • 1
Clement Amarnath
  • 4,779
  • 1
  • 16
  • 29
  • Correct me if I am wrong. The default connection time out for mongo java driver is 10000 ms , right? – Panneerselvam Jul 29 '15 at 17:20
  • 1
    https://api.mongodb.org/java/2.6/com/mongodb/MongoOptions.html#connectTimeoutsocketTimeout public int socketTimeout The socket timeout; this value is passed to Socket.setSoTimeout(int). 0 is default and infinite – Clement Amarnath Jul 31 '15 at 06:35