Re: Postgres SQLSTATE[08006] [7] timeout expired

Поиск
Список
Период
Сортировка
От Rob Sargent
Тема Re: Postgres SQLSTATE[08006] [7] timeout expired
Дата
Msg-id D5085C10-22E9-4A67-9647-08688638E701@gmail.com
обсуждение исходный текст
Ответ на Postgres SQLSTATE[08006] [7] timeout expired  (Howard Wells <mr284@protonmail.com>)
Список pgsql-general

> On Aug 24, 2019, at 4:42 PM, Howard Wells <mr284@protonmail.com> wrote:
>
> I have three servers behind a load balancer and a fourth server solely for Postgres 10 database that is not behind
theload balancer.  All four are behind the same firewall, with port 5432 open.  
>
> I have a simple browser-based html form to submit email addresses, usernames and passwords; the form submits through
ajQuery program that calls a php program.  
>
> I can navigate the browser to the IP address of the server that hosts the Postgres database and submit records to the
databasewith no problems.  When I navigate to the site's URL (which goes through the load balancer), I always get
"SQLSTATE[08006][7] timeout expired" after a short delay -- in other words, no connection.  
>
> The php program is very simple:
>
> <?php
> echo 'Hello ' . htmlspecialchars($_POST["firstname"]) . '!' ;
> echo PHP_EOL;
>
> $dsn = vsprintf('pgsql:host=%s;port=%s;dbname=%s;user=%s;password=%s', [
>     'host' => 'xxx.xx.xx.xx',
>     'port' => '5432',
>     'dbname' => '[DBNAME]',
>     'user' => '[USERNAME]',
>     'password' => '[PASSWORD]',
> ]);
>
> echo 'HTTP Referer ' . $_SERVER['HTTP_REFERER'];
> echo PHP_EOL;
>
> echo 'IP Address ' . $_SERVER["REMOTE_ADDR"];
> echo PHP_EOL;
>
> try{
> // create a PostgreSQL database connection
>
>   echo "I'm here now";
>   echo PHP_EOL;
>
> //ini_set("default_socket_timeout", 300);
> $pdo = new PDO($dsn);
> $pdo->setAttribute(PDO::ATTR_TIMEOUT, 300);
>
> // display a message if connected to the PostgreSQL successfully
> if($pdo){
> echo "Connected to the database successfully!";
> echo PHP_EOL;
> }
> }catch (PDOException $e){
> // report error message
> echo $e->getMessage();
> exit();
> }
>
> $pdo = null;
>
> ?>
>
> The echo messages are simply debugging progress messages for the browser's dev console.
>
> The pg_hba.conf has these lines enabled:
>
> pg_hba.conf:
> host    all             [username]   0.0.0.0/0               trust
> host    all             all             0.0.0.0/0               md5
> host    all             all              ::/0                   md5
> host    all             all              all                    md5
>
> The $_SERVER["REMOTE_ADDR"]; line shown in my PHP program above always comes back with the address of the load
balancer. 
>
> I'm new to Postgres, so any help with this connection problem will be very appreciated.  Thanks a lot.
>
>
Which load balancer and what are its configs?
Is this strictly accurate? "I can navigate the browser to the IP address of the server that hosts the Postgres
database”.i.e. Something is listening on port 80 of the database machine?  Or are you sending sql statements through
thefirewall directly to the db? 




В списке pgsql-general по дате отправления:

Предыдущее
От: Howard Wells
Дата:
Сообщение: Postgres SQLSTATE[08006] [7] timeout expired
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: Postgres SQLSTATE[08006] [7] timeout expired