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!
Published Sep 27, 2024
Version 1.0Jose_Manuel_Jurado
Microsoft
Joined November 29, 2018
Azure Database Support Blog
Follow this blog board to get notified when there's new activity