X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 3BE6AD1B91B for ; Thu, 26 Feb 2004 00:49:24 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 05032-05 for ; Wed, 25 Feb 2004 20:49:23 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by svr1.postgresql.org (Postfix) with ESMTP id 6CA03D1B4AA for ; Wed, 25 Feb 2004 20:49:20 -0400 (AST) Received: from news.hub.org (news.hub.org [200.46.204.72]) by news.hub.org (8.12.9/8.12.9) with ESMTP id i1Q0nJ1Y046043 for ; Thu, 26 Feb 2004 00:49:19 GMT (envelope-from news@news.hub.org) Received: (from news@localhost) by news.hub.org (8.12.9/8.12.9/Submit) id i1Q0mFSP045832 for pgsql-php@postgresql.org; Thu, 26 Feb 2004 00:48:15 GMT From: ljb X-Newsgroups: comp.databases.postgresql.interfaces.php Subject: Re: pg_connect timeout ignored Date: Thu, 26 Feb 2004 00:48:15 +0000 (UTC) Organization: Hub.Org Networking Services Lines: 26 Message-ID: References: X-Complaints-To: usenet@news.hub.org User-Agent: slrn/0.9.8.0 (Linux) To: pgsql-php@postgresql.org X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200402/43 X-Sequence-Number: 2591 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).