problem with connection to remote server

problem with connection to remote server

am 28.01.2010 10:51:41 von Ireneusz Tarnowski

Hi,

I have some PHP application and 2 postgreSQL remote servers.
All servers are runing under Solaris 10.

I can connect from application to one postgresql server and all work fine. I have to move database to second server. I export/import data. Check all data inside database - OK. I can't connect from php application into second postgresql server.

I test if it possible to connect using psql -h remote_server and I can connect. I check firewall's ... but I can connect between application serwer and postgresql server using CMD (psql). Only PHP application can't connect. Otherside ... the PHP application works fine with first postgresql server (and PHP configuration supports psql).

I compared TCP packets and it looks like the application and server drop connection after first 2 packets (ACK).

Can anybody understand problem and know answer?

best regards
Irek

--
Sent via pgsql-php mailing list (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php

Re: problem with connection to remote server

am 28.01.2010 11:02:35 von Andrew McMillan

--=-OGDia5HJ0hk+t2VhSCDj
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

On Thu, 2010-01-28 at 10:51 +0100, Ireneusz Tarnowski wrote:
> Hi,
>=20
> I have some PHP application and 2 postgreSQL remote servers.
> All servers are runing under Solaris 10.
>=20
> I can connect from application to one postgresql server and all work
> fine. I have to move database to second server. I export/import data.
> Check all data inside database - OK. I can't connect from php
> application into second postgresql server.
>=20
> I test if it possible to connect using psql -h remote_server and I
> can connect. I check firewall's ... but I can connect between
> application serwer and postgresql server using CMD (psql). Only PHP
> application can't connect. Otherside ... the PHP application works
> fine with first postgresql server (and PHP configuration supports
> psql).
>=20
> I compared TCP packets and it looks like the application and server
> drop connection after first 2 packets (ACK).

The place to look for error messages is in the PostgreSQL server log. I
would bet that it is rejecting the connection because the source ip/user
are different.

When you connect from the command-line it is probably using ident
information and that connection is being allowed, but the PHP
application will be running as the webserver user and will need
different credentials.

Check your pg_hba.conf file on the server and adjust it to let the
desired connection happen.

Cheers,
Andrew.

------------------------------------------------------------ ------------
http://andrew.mcmillan.net.nz/ Porirua, New Zealand
Twitter: _karora Phone: +64(272)DEBIAN
Be different: conform.
------------------------------------------------------------ ------------


--=-OGDia5HJ0hk+t2VhSCDj
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)

iEYEABECAAYFAkthYLUACgkQjJA0f48GgBLE/ACfYuLcgp4gbFCVzdVv/Ke3 pgOc
ac0An14X3s8KscK2g4RQPOPJkCXsooAZ
=G3Un
-----END PGP SIGNATURE-----

--=-OGDia5HJ0hk+t2VhSCDj--

Re: problem with connection to remote server

am 28.01.2010 13:43:00 von Bill Moran

In response to Andrew McMillan :

> On Thu, 2010-01-28 at 10:51 +0100, Ireneusz Tarnowski wrote:
> > Hi,
> >
> > I have some PHP application and 2 postgreSQL remote servers.
> > All servers are runing under Solaris 10.
> >
> > I can connect from application to one postgresql server and all work
> > fine. I have to move database to second server. I export/import data.
> > Check all data inside database - OK. I can't connect from php
> > application into second postgresql server.
> >
> > I test if it possible to connect using psql -h remote_server and I
> > can connect. I check firewall's ... but I can connect between
> > application serwer and postgresql server using CMD (psql). Only PHP
> > application can't connect. Otherside ... the PHP application works
> > fine with first postgresql server (and PHP configuration supports
> > psql).
> >
> > I compared TCP packets and it looks like the application and server
> > drop connection after first 2 packets (ACK).
>
> The place to look for error messages is in the PostgreSQL server log. I
> would bet that it is rejecting the connection because the source ip/user
> are different.
>
> When you connect from the command-line it is probably using ident
> information and that connection is being allowed, but the PHP
> application will be running as the webserver user and will need
> different credentials.
>
> Check your pg_hba.conf file on the server and adjust it to let the
> desired connection happen.

In addition to this, PHP will give some pretty useful error messages when
it can't connect. If you're not seeing those, then you should adjust
your application logic to log them, it will make your life a lot easier.
If they don't clearly define the problem, post them here ... I (and
others like me) have seen them enough to know what they indicate.

--
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/

--
Sent via pgsql-php mailing list (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php

Re: problem with connection to remote server

am 28.01.2010 14:36:14 von Ireneusz Tarnowski

> In addition to this, PHP will give some pretty useful error messages when
> it can't connect.=A0 If you're not seeing those, then you should adjust
> your application logic to log them, it will make your life a lot easier.
> If they don't clearly define the problem, post them here ... I (and
> others like me) have seen them enough to know what they indicate.

I have warning:

Warning: pg_connect() [function.pg-connect]: Unable to connect to PostgreSQ=
L server: could not connect to server: No such file or directory Is the ser=
ver running on host "XX.XX.XX.XX" and accepting TCP/IP connections on port =
5432? in /export/sun1000/XXXXXXX/public_html/dbtest.php on line 10

And nothing more. Postgresql log, apache error log and php error log write =
nothing about this connection.

--
Irek


--=20
Sent via pgsql-php mailing list (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php

Re: problem with connection to remote server

am 28.01.2010 14:46:47 von Bill Moran

In response to Ireneusz Tarnowski :

> > In addition to this, PHP will give some pretty useful error messages wh=
en
> > it can't connect.=A0 If you're not seeing those, then you should adjust
> > your application logic to log them, it will make your life a lot easier.
> > If they don't clearly define the problem, post them here ... I (and
> > others like me) have seen them enough to know what they indicate.
>=20
> I have warning:
>=20
> Warning: pg_connect() [function.pg-connect]: Unable to connect to Postgre=
SQL server: could not connect to server: No such file or directory Is the s=
erver running on host "XX.XX.XX.XX" and accepting TCP/IP connections on por=
t 5432? in /export/sun1000/XXXXXXX/public_html/dbtest.php on line 10
>=20
> And nothing more. Postgresql log, apache error log and php error log writ=
e nothing about this connection.

This is usually the result of a network problem. hba problems are usually
reported as such by PHP. I would first 2x check the obvious ... did you
mistype the IP or hostname in the connection string? Check firewall logs
to ensure it's not being blocked by something. Run tcpdump on the server
to see if it's getting the syn packets.

--=20
Bill Moran
http://www.potentialtech.com
http://people.collaborativefusion.com/~wmoran/

--=20
Sent via pgsql-php mailing list (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php

Re: problem with connection to remote server

am 29.01.2010 11:52:52 von Jasen Betts

On 2010-01-28, Ireneusz Tarnowski wrote:
>> In addition to this, PHP will give some pretty useful error messages w=
hen
>> it can't connect.  If you're not seeing those, then you should ad=
just
>> your application logic to log them, it will make your life a lot easie=
r.
>> If they don't clearly define the problem, post them here ... I (and
>> others like me) have seen them enough to know what they indicate.
>
> I have warning:
>
> Warning: pg_connect() [function.pg-connect]: Unable to connect to Postg=
reSQL server: could not connect to server: No such file or directory Is t=
he server running on host "XX.XX.XX.XX" and accepting TCP/IP connections =
on port 5432? in /export/sun1000/XXXXXXX/public_html/dbtest.php on line 1=
0
>
> And nothing more. Postgresql log, apache error log and php error log wr=
ite nothing about this connection.

"No such file or directory" is ENOENT but I can't see how errno is
getting set to that on an IP socket connectiom.

--=20
Sent via pgsql-php mailing list (pgsql-php@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-php