[Dev] PostgreSQL connection timeout

Richard O. Hammer ROHammer at EarthLink.net
Wed Jan 14 09:36:29 EST 2004


Jon Carnes wrote:
> Did you see this entry?
>  http://forums.devshed.com/t45649/s.html
> 
> This guy had no problems if both machines were on the same subnet since
> the connection was directly machine to machine (no firewall or router
> in-between).

Thank you, Jon.  I had not found that entry.  My two machines are both 
connected to local ports on a Linksys cable/DSL router (this router 
also uplinks to my DSL modem).  So I believe it would be accurate to 
say my two machines are both in the same subnet; they are 192.168.1.2 
and 192.168.1.3 .  I don't suppose that is my problem.

I've just discovered /proc/sys/net/ipv4/tcp_keepalive_time, and I'm 
saying Hmmm.

Also, I suspect one factor may be that my Windows 2000 machine goes 
into standby when I walk away from it for 25 minutes, and my 
connection-reset problems with PostgreSQL on my RH7.3 machine all 
occur during these long intervals, so far at least.  I don't know 
exactly which services continue to operate during Windows standby, but 
I wonder if TCP stops sending keepalive segments.


> On Tue, 2004-01-13 at 18:10, Richard O. Hammer wrote:
> 
>>I have PostgreSQL 7.3.2 running on Red Hat 7.3, and I am connecting to 
>>it from a Java Virtual Machine on Windows 2000.  Usually it runs fine. 
>>   But sometimes it breaks, seemingly with a connection timeout.  I 
>>hope for suggestions on what to do about this.
>>
>>When my problem happens, I get a stack trace like this on the client 
>>(Windows) side:
>>
>>An I/O error occurred while reading from backend - Exception: 
>>java.net.SocketException: Connection reset by peer: JVM_recv in socket 
>>input stream read
>>Stack Trace:
>>
>>java.net.SocketException: Connection reset by peer: JVM_recv in socket 
>>input stream read
>>	at java.net.SocketInputStream.socketRead0(Native Method)
>>	at java.net.SocketInputStream.read(SocketInputStream.java:116)
>>	at java.io.BufferedInputStream.fill(BufferedInputStream.java:183)
>>	at java.io.BufferedInputStream.read(BufferedInputStream.java:201)
>>	at org.postgresql.PG_Stream.ReceiveChar(PG_Stream.java:138)
>>	at org.postgresql.core.QueryExecutor.execute(QueryExecutor.java:71)
>>...
>>
>>
>>And on the Linux server side I see the following message in
>>/var/log/messages.  I believe this message relates to the problem I am 
>>having.
>>
>>Jan 10 22:54:59 r postgres[27572]: [1] LOG:  pq_recvbuf: recv() 
>>failed: Connection timed out
>>
>>Searching, I found my error message mentioned on one PostgreSQL email 
>>list.  The reply given there told that this is not a PostgreSQL 
>>problem, but an underlying kernel or TCP thing on Linux.
>>
>>So, I don't know what to ask exactly, but is there a default TCP 
>>connection timeout on Linux?  that I could maybe set?
>>
>>Thanks,
>>Rich Hammer



More information about the Dev mailing list