pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: ljb <ljb220@mindspring.com>
To: pgsql-php@postgresql.org
Subject: Re: pg_connect timeout ignored
Date: Thu, 26 Feb 2004 00:48:15 +0000 (UTC)
Message-ID: <c1jfof$1cd4$1@news.hub.org> (raw)
References: <Vgu_b.47533$nI7.29326@nntp-post.primus.ca>

private@xxxxxxx.com wrote:
> I'm testing the connect_timeout option in pg_connect but the library seems
> to ignore it. I set the pg_connect to connect to an invalid host IP and set
> the connect_timeout=8 but the function returns in 30 seconds or more.
>
> $DB = pg_connect(host=169.2.2.22 user=postgres database=xyz
> connect_timeout=8);
>
> I'm running Redhat 9 on Postgresql 7.4 and php-pgsql-4.2.2-17.2.
>
> Any idea how the connect_timeout option works on PHP Pgsql?

It just passes the whole connection string through to the PostgreSQL
library libpq. So it isn't a problem with PHP. I tried it and it works for
me. I added "connect_timeout=2" to my connection string, and I got this
error (in 2 seconds) when trying to connect to an invalid IP address:

  Warning: pg_connect() [function.pg-connect.html]: Unable to connect to
  PostgreSQL server: timeout expired . in ...

I had to use 2 seconds. With 3 seconds or longer, I get a "no route to host,
is the server running..." error before it times out.

I'm running PostgreSQL-7.4.1 and  PHP-4.3.3 on Slackware 9.1 Linux. If the
problem you are having is fixed by an upgrade, I would try PostgreSQL-7.4.1
first (because I don't think PHP will affect it).



view thread (2+ messages)

Message-ID: <c1jfof$1cd4$1@news.hub.org>
Permalink:  ../c1jfof$1cd4$1@news.hub.org/
Also on:    postgresql.org/message-id/c1jfof$1cd4$1@news.hub.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: ljb220@mindspring.com
  Subject: Re: pg_connect timeout ignored
  In-Reply-To: <c1jfof$1cd4$1@news.hub.org>
  References: <Vgu_b.47533$nI7.29326@nntp-post.primus.ca> <c1jfof$1cd4$1@news.hub.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox