Java driver connect/disconnect every minute exactly

I’ve been digging for a few days trying to solve my java driver connect/disconnect to no avail. I have a Spring application using the sync driver, and configured with 0 (zero) idle timeout and 0 (zero) lifetime timeout, yet I see in my logs that the application connects, and after exactly one minute (almost the to the millisecond) disconnects. And that keeps repeating, even under heavy system load.

Any ideas what I’m doing wrong, and how I can keep my connections open?

Many thanks!

Try bumping up client log levels to DEBUG. In particular for 'org.mongodb.driver.cluster" and “org.mongodb.driver.connection”. It might offer some clues as to why the connections are getting closed.

See https://www.mongodb.com/docs/drivers/java/sync/current/fundamentals/logging/ for further information.

1 Like

Ok, I think I’m onto something…

The behaviour I’m seeing is because of the idle timeout which seems to close all connections and reopens them despite a minimum required number of connections!? Is that normal?

What I would expect is for all minimum number of connections to stay open for the life of the application, and anything above the minimum would close according to the idle timeout or lifetime timeout.

If I set both timeout values to 0 (zero), the connection/disconnection stops, but does that mean that my pool never shrinks during lighter loads?

Thanks again!

That’s not how it’s specified. Even the minimum number of connections are subject to the idle and lifetime limits.

Thanks for the prompt response.

Then is it recommended that the idle and lifetime timeouts be set to zero in production?