When connecting to a remote server PostgreSQL on a network, inactivity will automatically disconnect for a longer period of time and is not conducive to operation. Figured out, this problem was resolved when the following network configuration was used on the server. #man 7 TCP net.ipv4.tcp_keepalive_time = 600net.ipv4.tcp_keepalive_probes = 3NET.IPV4.TCP_KEEPALIVE_INTVL = 15 also pay attention to post Gresql.conf in the following settings: #tcp_keepalives_idle = 0 # Tcp_keepidle, in seconds; 0 selects the system default
#tcp_keepalives_interval = 0 # TCP_KEEPINTVL, in seconds;0 selects the system default
#tcp_keepalives_count = 0 # tcp_keepcnt;0 Selects the system default is DEBIAN7, the default timeout setting is too long and the network condition is poor, which leads to this Problem. The idea of this configuration is to have the PG emit probe packets more frequently to keep the TCP connection.
Processing of PostgreSQL remote connection interrupts