I had a problem while trying to fault tolerance mongodb with java driver.
I have a primary / secondary mongodb cluster, namely server1 and server2.
When I kill primary server1 in order to simulate a failure, server2 becomes the main one in a few seconds, and my applications that access the mango using the java driver start using the new primary server2.
When I restarted server1, it takes its main role in a few seconds, but then my application, instead of connecting to server 1, is still trying to connect to server2 and, since it is now in a secondary state, itβs checked! All requests are resolved by this error:
com.mongodb.MongoServerSelectionException: Unable to connect to any server that matches {serverSelectors=[ReadPreferenceServerSelector{readPreference=primary}, LatencyMinimizingServerSelector{acceptableLatencyDifference=15 ms}]}
I am using mongodb 2.6 and java driver 2.12. I do not pass any parameter to my MongoClient, which is created using all nodes of my cluster.
Any help would be appreciated.
Hi,
Loic
java mongodb
loicmathieu
source share