dlst
06-26-05, 19:33
On my web box I have a problem with PHP resolving host names. Host names resolve perfectly from the command line:
<?php
// http://www.php.net/ is 64.246.30.37
$fd = fopen( "http://www.php.net/", "r" );
if( !$fd )
{
echo "Cannot open URL";
} else {
while ( !feof( $fd ) ) {
$buffer = fgets( $fd, 4096 );
echo $buffer;
}
fclose ( $fd );
}
?>
produces the following error codes:
Warning: fopen(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /hsphere/local/home/XXXuser/XXXXXXX.com/test/test.php on line 3
Warning: fopen(http://www.rackspace.com/): failed to open stream: Resource temporarily unavailable in /hsphere/local/home/XXXuser/XXXXXXX.com/test/test.php on line 3
Cannot open URL
that seem to be described in php.net as bug 11058:
http://bugs.php.net/bug.php?id=11058
The code is supposed to read the remote site home page instead of failing the dns query.
I ran this code on another server and it did work, I am running RedHat's default php 4.3.2.
I ran this script successfully on the command line (on the problem server) using psoft's php build with:
/root/php/php-4.3.11/sapi/cli/php /hsphere/local/home/XXXuser/XXXXXX.com/test/test.php
This command line php reads /usr/local/lib/php.ini while the php apache module loads /hsphere/local/config/httpd/php.ini.
That made me believe that either the php apache module had a problem or apache itself when resolving names.
When I traced the system calls in the command line, the client uses the system's dns:
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("X.X.X.X")}, 28) = 0
when I traced apache's php, I saw the same atempt of connection to a different set of nameservers:
[pid 4509] connect(13, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("X.X.X.X")}, 28) = 0
(where X.X.X.X is the IP address of the physical box, not the Nameservers)
[pid 4509] connect(13, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("Y.Y.Y.Y")}, 28) = 0
(where Y.Y.Y.Y is the IP address of another physical box, not the Nameservers)
This is what happened right after:
[pid 4509] recvfrom(13, 0xbfff85c0, 1024, 0, 0xbfff7ad8, 0xbfff7a90) = -1 ECONNREFUSED (Connection refused)
Instead of seeing:
recvfrom(3, "\27h\201\200\0\1\0\2\0\4\0\4\3www\3php\3net\0\0\1\ 0\1\300"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_a
ddr=inet_addr("64.49.236.16")}, [16]) = 214
The conclusion is that php is attempting to resolve using the incorrect nameservers, but the command line resolves just fine.
This is where I hit a wall. Does anyone have any advice on where to go next? I've already filled out a trouble ticket with Psoft, but this is the third time they are claiming "your configuration is fine because hosts resolve from the command line"... pretty useless considering the information above.
Anyway, hopefully someone here can help! Thanks!
<?php
// http://www.php.net/ is 64.246.30.37
$fd = fopen( "http://www.php.net/", "r" );
if( !$fd )
{
echo "Cannot open URL";
} else {
while ( !feof( $fd ) ) {
$buffer = fgets( $fd, 4096 );
echo $buffer;
}
fclose ( $fd );
}
?>
produces the following error codes:
Warning: fopen(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /hsphere/local/home/XXXuser/XXXXXXX.com/test/test.php on line 3
Warning: fopen(http://www.rackspace.com/): failed to open stream: Resource temporarily unavailable in /hsphere/local/home/XXXuser/XXXXXXX.com/test/test.php on line 3
Cannot open URL
that seem to be described in php.net as bug 11058:
http://bugs.php.net/bug.php?id=11058
The code is supposed to read the remote site home page instead of failing the dns query.
I ran this code on another server and it did work, I am running RedHat's default php 4.3.2.
I ran this script successfully on the command line (on the problem server) using psoft's php build with:
/root/php/php-4.3.11/sapi/cli/php /hsphere/local/home/XXXuser/XXXXXX.com/test/test.php
This command line php reads /usr/local/lib/php.ini while the php apache module loads /hsphere/local/config/httpd/php.ini.
That made me believe that either the php apache module had a problem or apache itself when resolving names.
When I traced the system calls in the command line, the client uses the system's dns:
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("X.X.X.X")}, 28) = 0
when I traced apache's php, I saw the same atempt of connection to a different set of nameservers:
[pid 4509] connect(13, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("X.X.X.X")}, 28) = 0
(where X.X.X.X is the IP address of the physical box, not the Nameservers)
[pid 4509] connect(13, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("Y.Y.Y.Y")}, 28) = 0
(where Y.Y.Y.Y is the IP address of another physical box, not the Nameservers)
This is what happened right after:
[pid 4509] recvfrom(13, 0xbfff85c0, 1024, 0, 0xbfff7ad8, 0xbfff7a90) = -1 ECONNREFUSED (Connection refused)
Instead of seeing:
recvfrom(3, "\27h\201\200\0\1\0\2\0\4\0\4\3www\3php\3net\0\0\1\ 0\1\300"..., 1024, 0, {sa_family=AF_INET, sin_port=htons(53), sin_a
ddr=inet_addr("64.49.236.16")}, [16]) = 214
The conclusion is that php is attempting to resolve using the incorrect nameservers, but the command line resolves just fine.
This is where I hit a wall. Does anyone have any advice on where to go next? I've already filled out a trouble ticket with Psoft, but this is the third time they are claiming "your configuration is fine because hosts resolve from the command line"... pretty useless considering the information above.
Anyway, hopefully someone here can help! Thanks!