Thread: About could not connect to server: Connection timed out

About could not connect to server: Connection timed out

From
黄永卫
Date:

Hi,

 

 When I use ecpg  code to download File from database, error  occurred  occasionally as below:

could not connect to server: Connection timed out    Is the server running on host "DB" and accepting        TCP/IP connections on port 5432?

 

This my code:

 

                  conn = PQsetdbLogin(host, NULL, NULL, NULL, database, username, "") ;

                if (PQstatus (conn) != CONNECTION_BAD){

                PQexec(conn, "BEGIN");

                if (lo_export(conn,oidImage_Data,chImageName) == -1) {

                    printf("PQSTATUS=%s \n",PQerrorMessage(conn));

                    PQfinish (conn) ;

                    printf("EXPORT %s ERROR! SQL STATE =   %s\n ",chImageName,sqlca.sqlstate);

                }

                printf("PQSTATUS=%s \n",PQstatus(conn));

                PQexec(conn, "COMMIT");

 

This log was found in postgres.log:

Oct 18 10:44:35 SUC02 postgres[10159]: [7-1] LOG:  database system is ready

Oct 18 10:44:35 SUC02 postgres[10159]: [8-1] LOG:  transaction ID wrap limit is 3343152371, limited by database "template1"

Oct 18 10:46:11 SUC02 postgres[10997]: [2-1] LOG:  unexpected EOF on client connection

Oct 18 10:46:11 SUC02 postgres[15899]: [2-1] LOG:  could not receive data from client: Connection reset by peer

Oct 18 10:46:11 SUC02 postgres[15899]: [3-1] LOG:  unexpected EOF on client connection

 

What is the problem ? What should I investigate ?

Please help ! Thank you very much !

 

Ray Huang

2009-10-20

 

 

Re: About could not connect to server: Connection timed out

From
Craig Ringer
Date:
On Tue, 2009-10-20 at 12:12 +0800, 黄永卫 wrote:
>
> Oct 18 10:46:11 SUC02 postgres[10997]: [2-1] LOG:  unexpected EOF on
> client connection
> Oct 18 10:46:11 SUC02 postgres[15899]: [2-1] LOG:  could not receive
> data from client: Connection reset by peer

That looks a lot like lower-level networking issues. Is there any NAT
between client and server? What sort of network connects the two? Is
there any packet loss on the network? Is there any sort of firewall on
or between the client and server?

--
Craig Ringer


Re: About could not connect to server: Connection timed out

From
Johan Nel
Date:
Craig Ringer wrote:
> On Tue, 2009-10-20 at 12:12 +0800, 黄永卫 wrote:
>> Oct 18 10:46:11 SUC02 postgres[10997]: [2-1] LOG:  unexpected EOF on
>> client connection
>> Oct 18 10:46:11 SUC02 postgres[15899]: [2-1] LOG:  could not receive
>> data from client: Connection reset by peer
>
> That looks a lot like lower-level networking issues. Is there any NAT
> between client and server? What sort of network connects the two? Is
> there any packet loss on the network? Is there any sort of firewall on
> or between the client and server?

Agree, what is the timeout value set to in the connection string?
Increase to something Timeout=60 or bigger.

Johan Nel
Pretoria, South Africa.

答复: [GENERAL] About could not connect to server: Connection timed out

From
黄永卫
Date:
Thanks for you reply!
Server and the client conect with the same CISCO switch.
We have checked the switch ,but no CRC error occur.
This issue always occur after we reboot the server and the postgres service
just   become ready statu for serval several minutes.
It is possible that server's performance cause the issue (server is too busy
on that moment) ?

Thank you!

Ray Huang

-----邮件原件-----
发件人: Craig Ringer [mailto:craig@postnewspapers.com.au]
发送时间: 2009年10月20日 星期二 12:34
收件人: 黄永卫
抄送: pgsql-general@postgresql.org
主题: Re: [GENERAL] About could not connect to server: Connection timed out

On Tue, 2009-10-20 at 12:12 +0800, 黄永卫 wrote:
>
> Oct 18 10:46:11 SUC02 postgres[10997]: [2-1] LOG:  unexpected EOF on
> client connection
> Oct 18 10:46:11 SUC02 postgres[15899]: [2-1] LOG:  could not receive
> data from client: Connection reset by peer

That looks a lot like lower-level networking issues. Is there any NAT
between client and server? What sort of network connects the two? Is
there any packet loss on the network? Is there any sort of firewall on
or between the client and server?

--
Craig Ringer