Using a network trace, I observed that once the connections are established and to keep them active, the operating system sends a TCP Keep-Alive, which indicates how often it checks that the connection remains active in the HikariCP connection pool.
In this situation, my first idea for idle connection in the HikariCP pool was to configure KeepAliveTime parameter. HikariCP will send a lightweight query (such as SELECT 1) to idle connections that have been inactive for longer than this parameter value. This keeps the connection alive, avoiding unexpected disconnections by external systems.
We could see the results in the following network trace and SQL Profiler.
Network setups, such as those involving firewalls, have policies that close idle connections after a certain period. If a connection is closed in this way and keepalivetime is not set, HikariCP will only detect the closure when the connection is requested from the pool.
Enjoy!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.