I’m using the Mongo Java driver (2.8.0) to connect to a Mongo instance.
I noticed that if I restart mongod, then the first operation after the restart (even a simple count()) always fails with EOFException or a Broken pipe.
I’m using the following Mongo options:
opts.autoConnectRetry = true;
opts.maxAutoConnectRetryTime = 2000L;
opts.connectTimeout = 30000;
opts.socketTimeout = 60000;
Is there a way to tell the driver to try to re-establish the connections? I thought that “autoReconnectRetry” will do that, but that only works after the connection is “discovered” (through a single failed operation) to be broken.
The AutoConnectRetry option will retry when opening a connection to the server, but doesn’t guarantee you won’t get a read exception. You still need to handle exceptions in your application and retry if appropriate.
Blurb from the docs: