简体   繁体   中英

Postgres Connection drops after 15 mins of idleness

We have a java application that uses Postgres v11 along with PgBouncer for connection pooling. When we keep the application idle for 15 mins, the connection drops(JDBC). The database is hosted on Amazon AWS

The same is observed in Pgadmin.

We tried TCP keepalive and few others. Nothing works.

Any ideas?

Most connection pools have setting like "keep alive time", "keep alive query". You can set them in the Java application to prevent network timeout.

For example, for HikariCP:

  • keepaliveTime - "This property controls how frequently HikariCP will attempt to keep a connection alive, in order to prevent it from being timed out by the database or network infrastructure"

https://github.com/brettwooldridge/HikariCP#frequently-used

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM