ID: 49965
User updated by: ed at bellcpa dot com
Reported By: ed at bellcpa dot com
-Status: Feedback
+Status: Open
Bug Type: MySQLi related
Operating System: Windows Server 2008
PHP Version: 5.3.0
New Comment:
Ulf,
Here is the fsockopen() result, looks like timeout works as expected:
C:\temp2>php testme.php
PHP Warning: fsockopen(): unable to connect to
tcp://192.168.201.222:3306 (A co
nnection attempt failed because the connected party did not properly
respond aft
er a period of time, or established connection failed because connected
host has
failed to respond.
) in C:\temp2\testme.php on line 6
PHP Stack trace:
PHP 1. {main}() C:\temp2\testme.php:0
PHP 2. fsockopen() C:\temp2\testme.php:6
Warning: fsockopen(): unable to connect to tcp://192.168.201.222:3306
(A connect
ion attempt failed because the connected party did not properly respond
after a
period of time, or established connection failed because connected host
has fail
ed to respond.
) in C:\temp2\testme.php on line 6
Call Stack:
0.0312 324832 1. {main}() C:\temp2\testme.php:0
0.0491 325280 2. fsockopen() C:\temp2\testme.php:6
bool(false)
int(10060)
string(185) "A connection attempt failed because the connected party
did not pro
perly respond after a period of time, or established connection failed
because c
onnected host has failed to respond.
"
float(5.1100761890411)
Previous Comments:
------------------------------------------------------------------------
[2009-10-28 17:07:43] [email protected]
Ah, looks I'm wrong on the loop. PHP should iterate over all possible
hosts and only decrement remaining time if there are multiple hosts...
Anyway, fsockopen() would be interesting.
------------------------------------------------------------------------
[2009-10-28 16:54:33] [email protected]
Hi Ed,
as you may know from the Wireshark protocol you provided
(mysql-noserver.pcap - MySQL is offline) there is a TCP SYN->RST,ACK
ping-pong between the client machine and the server.
PHP tries to establish a connection and sends SYN. The server's
response is RST (, ACK) indicating that no process on the server is
wating for requests on the requested port (MySQL is offline).
At this point PHP should get ECONNREFUSED from connect() and bubble up
the error. But it seems as if this is not the case. According to the
Wireshark protocol the first SYN->RST,ACK is followed by another
connection attempt after about 0.5s which fails. PHP continues to make
another connection attempt after 1s which fails again.
The ping-pong should start because PHP recognizes after 0.5s
respectively 1s that there is time left for more connection attempts
(you set the connect timeout to 5s).
I don't know why the protocol shows no more records after 1s.
However, can you try using fsockopen() to connect to the MySQL host if
MySQL is offline?
Something like this:
sapi/cli/php -r '$start = microtime(true); $errno = 0; $error = ""; $fp
= fsockopen("tcp://192.168.201.222", 3306, $errno, $error, 5);
var_dump($fp); var_dump($errno); var_dump($error);
var_dump(microtime(true) - $start); '
Again, I'd be interested in the Wireshark protocol (unless it is
blocking endless).
Thanks!
Ulf
------------------------------------------------------------------------
[2009-10-27 21:19:50] ed at bellcpa dot com
Hi Ulf,
I tried a 5.3.2-dev VC9 x86 thread-safe snapshot (not sure how to
obtain 5.3.1) with same results. Also tried a 5 second
default_socket_timeout with no effect.
Will send the captures to you by email.
Thanks
------------------------------------------------------------------------
[2009-10-27 10:06:56] [email protected]
Regarding wireshark protocol: yes, please do mail them to me or offer
them for download anywhere (make sure they don't show any confidential
data, e.g. server IP, username, password!)
Thanks!
Ulf
------------------------------------------------------------------------
[2009-10-27 10:04:54] [email protected]
60s - we are back to some config problem. Can you try change the
default_socket_timeout? Can you try a 5.3.1 snapshot?
Thanks!
Ulf
------------------------------------------------------------------------
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/49965
--
Edit this bug report at http://bugs.php.net/?id=49965&edit=1