Thread: Timeout Value on network error

Timeout Value on network error

From
ecolgan@shiftwatch.com
Date:
I'm new to Postgres, but have been impressed so far.
We're using a remote Postgres server to view video data.  It works
well, but we're having a hard time making our app robust when the
network fails.  For example, PQexec does not return consistently when
the cable is disconnected.  Is there a timeout value that we can
configure, so all PQ* functions return consistently?


Re: Timeout Value on network error

From
Michael Fuhr
Date:
On Mon, Oct 30, 2006 at 11:46:01AM -0800, ecolgan@shiftwatch.com wrote:
> We're using a remote Postgres server to view video data.  It works
> well, but we're having a hard time making our app robust when the
> network fails.  For example, PQexec does not return consistently when
> the cable is disconnected.

Network connections use TCP, which was designed to be robust over
unreliable networks.  A TCP connection isn't supposed to fail right
away in the face of network problems like disconnected cables;
instead, TCP retransmits packets with the hope that connectivity
will soon be re-established.

> Is there a timeout value that we can configure, so all PQ* functions
> return consistently?

You could use asynchronous command processing with poll() or select().

http://www.postgresql.org/docs/8.1/interactive/libpq-async.html

--
Michael Fuhr