Question

Our current connection configuration looks like this:

MongoClientOptions.builder()
    .autoConnectRetry(true).maxAutoConnectRetryTime(1200000)
    .socketTimeout(30000).connectTimeout(15000).build();
     // SocketTimeout: 30s, ConnectionTimeout 15s, ReconnectRetry: 20min

autoConnectRetry and maxAutoConnectRetryTime are deprecated in the current version (source code) and will be removed: "There is no replacement for this method. Use the connectTimeout property to control connection timeout."

I thought retries and connection timeouts were two different things. Does anyone know why this was changed and what (internal) implications this has?

Was it helpful?

Solution

There was a lot of confusion about the meaning of autoConnectRetry. Most people think it means that, if an operation failed due to an IOException, the driver would retry the operation until maxAutoConnectRetryTime elapsed. But that is not the case.

All it means is that, on calls to Socket.connect(), the driver retries a failed attempt to connect until maxAutoConnectRetryTime elapsed. But this is exactly what connectTimeout is for. The only additional capability of autoConnectRetry is so that you can specify a longer connect timeout than is allowed by the underlying operating system (which typically enforces a max connect timeout that caps the value that the user specifies).

Due to this confusion, the lack of value of the feature, and the fact that none of the other MongoDB drivers support this feature, we decided to deprecate it (and remove it in the next major release).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top