Re: TCP keepalive support for libpq

Kris Jurka <books@ejurka.com>

From: Kris Jurka <books@ejurka.com>
To: Andrew Chernow <ac@esilo.com>
Cc: Magnus Hagander <magnus@hagander.net>, daveg <daveg@sonic.net>, Tollef Fog Heen <tollef.fog.heen@collabora.co.uk>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2010-02-11T17:23:03Z
Lists: pgsql-hackers

On Thu, 11 Feb 2010, Andrew Chernow wrote:

>
> Although, I think Dave's comments have made me change my mind about this 
> patch.  Looks like it serves a good purpose.  That said, there is no 
> guarentee the driver will implement the new feature ... JDBC seems to 
> lack the ability to get the backing Socket object but java can set 
> socket options. Maybe a JDBC kong fu master knows how to do this.

Use the tcpKeepAlive connection option as described here:

http://jdbc.postgresql.org/documentation/84/connect.html#connection-parameters

Java can only enable/disable keep alives, it can't set the desired 
timeout.

http://java.sun.com/javase/6/docs/api/java/net/Socket.html#setKeepAlive%28boolean%29

Kris Jurka