Bug #54896 [Asn]: Connection to localhost doesn't work in Apache SAPI but works in CLI and CGI
| From: | cataphract@php.net | Date: | Wed, 01 Jun 2011 14:32:29 +0000 |
| Subject: | Bug #54896 [Asn]: Connection to localhost doesn't work in Apache SAPI but works in CLI and CGI | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-161105@lists.php.net to get a copy of this message | ||
Edit report at http://bugs.php.net/bug.php?id=54896&edit=1
ID: 54896
Updated by: cataphract@php.net
Reported by: neweracracker at gmail dot com
Summary: Connection to localhost doesn't work in Apache SAPI
but works in CLI and CGI
Status: Assigned
Type: Bug
Package: Streams related
Operating System: Windows 7
PHP Version: 5.3SVN-2011-05-20 (snap)
Assigned To: cataphract
Block user comment: N
Private report: N
New Comment:
Works here:
Script: var_dump(fsockopen("localhost", 9876));
ncat -4 -k -l 9876 -v -v
15:22:42,3106124 httpd.exe 2504 TCP Reconnect 0:0:0:0:0:0:0:1:6660 ->
0:0:0:0:0:0:0:1:9876 SUCCESS Length: 0, seqnum: 0, connid: 0
15:22:42,8106355 httpd.exe 2504 TCP Reconnect 0:0:0:0:0:0:0:1:6660 ->
0:0:0:0:0:0:0:1:9876 SUCCESS Length: 0, seqnum: 0, connid: 0
15:22:42,8210523 httpd.exe 2504 TCP Connect 127.0.0.1:6661 ->
127.0.0.1:9876 SUCCESS Length: 0, mss: 1460, sackopt: 1, tsopt: 0,
wsopt: 1, rcvwin: 8192, rcvwinscale: 8, sndwinscale: 8, seqnum: 0,
connid: 0
15:22:42,8216731 httpd.exe 2504 TCP Disconnect 127.0.0.1:6661 ->
127.0.0.1:9876 SUCCESS Length: 0, seqnum: 0, connid: 0
So tries IPv6, fails, then tries IPv4.
Now with a process listening on IPv6:
ncat -6 -k -l 9876 -v -v
15:25:44,6140323 httpd.exe 2504 TCP Accept 0:0:0:0:0:0:0:1:6672 ->
0:0:0:0:0:0:0:1:9876 SUCCESS Length: 0, mss: 1440, sackopt: 1, tsopt: 0,
wsopt: 1, rcvwin: 8192, rcvwinscale: 8, sndwinscale: 8, seqnum: 0,
connid: 0
15:25:44,6238583 httpd.exe 2504 TCP Disconnect 0:0:0:0:0:0:0:1:6672 ->
0:0:0:0:0:0:0:1:9876 SUCCESS Length: 0, seqnum: 0, connid: 0
Tries with IPv6 and works the first time.
As expected. The only normal case when "127.0.0.1" would work but not
localhost with a service listening only with IPv4 is if the packet for
the initial attempt with IPv6 would get dropped instead of the OS
getting a RST packet back rejecting the connection.
Previous Comments:
------------------------------------------------------------------------
[2011-06-01 16:15:55] neweracracker at gmail dot com
127.0.0.1 works
localhost doesn't
------------------------------------------------------------------------
[2011-06-01 16:04:34] pajoye@php.net
And please try it.... that's what has been asked. Asking Gustavo to test
again is
good but in the end, we like to know that you don't see the problem
anymore.
------------------------------------------------------------------------
[2011-06-01 16:03:59] pajoye@php.net
Does your example that both 127.0.0.1 and localhost work when only IPv4
is used?
------------------------------------------------------------------------
[2011-06-01 16:02:17] neweracracker at gmail dot com
I don't see this problem when apache is listening in ipv6 but I see when
only ipv4 is being listened.
Please try my mysql example. If this is fixed. then bug #54832 will be
fixed as well since mysqlnd uses streams.
------------------------------------------------------------------------
[2011-06-01 15:56:56] pajoye@php.net
@neweracracker at gmail dot com
He said it cannot reproduce it. Do you still see this problem?
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/bug.php?id=54896
--
Edit this bug report at http://bugs.php.net/bug.php?id=54896&edit=1