ID: 49965 Updated by: u...@php.net Reported By: ed at bellcpa dot com -Status: Open +Status: Feedback Bug Type: MySQLi related Operating System: Windows Server 2008 PHP Version: 5.3.0 New Comment:
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 Previous Comments: ------------------------------------------------------------------------ [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] u...@php.net 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] u...@php.net 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 ------------------------------------------------------------------------ [2009-10-26 21:10:09] ed at bellcpa dot com After further testing: The php_errors.log messages previously mentioned are logged exactly 60 sec after a connection attempt is made so some timeout is likely in effect. Also, the script remains running in a "hung" state after the errors are logged. Post connection timeout is not a concern here, instead the issue is with the length of the timeout when MySQL server is purposely not online. I have Wireshark captures for when the MySQL server is offline and connection times out as well as when MySQL is online and connection succeeds right away. Can I email these to you? I am using mysqli on 5.3.0 with default settings, shouldn't mysqlnd be used by default? I will try a snapshot soon once I find the time to test. Thanks! ------------------------------------------------------------------------ [2009-10-23 19:24:29] u...@php.net PS: don't rely on connect timeout of libmysql - it does not work in every case. Check bugs.mysql.com. ------------------------------------------------------------------------ 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