Programmatically set connectTimeout and read it from MongoClient


I was going through the timeout handling section and wrote the code to set the connectTimeout using MongoSetting builder to check my other options (apart from setting in the url)

.applyToSocketSettings(builder -> builder.connectTimeout(2000, TimeUnit.MILLISECONDS))

After that I was writing a unitary test to check this value and couldn’t find a method to read the connection properties from MongoClient. Is there other option to do that?

Thank you.

In, search for connectTimeout.

I guess I was not clear in my first post. I solved the ticket using the connection string parameter and was trying different options (using the builders) and couldn’t find a way to read the configurations from a unitary test reading straight from the client object (and not from the connection string). I read the reference page and that is strict for connection string parameters.

I will checkout the driver code from github later to investigate further if there is a way. :slight_smile: