ID: 49965 User updated by: ed at bellcpa dot com Reported By: ed at bellcpa dot com Status: Bogus Bug Type: MySQLi related Operating System: Windows Server 2008 PHP Version: 5.3.0 New Comment:
Oh but I did search and have seen #49511 propr to submitting.... #49511 mainly focuses on a query timeout and not a connection timeout, which is my issue. MYSQL_OPT_CONNECT_TIMEOUT mentioned is unaddressed. Also tried ini_set('default_socket_timeout', 5) as suggested in that submission with no effect. Previous Comments: ------------------------------------------------------------------------ [2009-10-23 10:22:33] j...@php.net See bug #49511, and thank you for not searching before submitting.. ------------------------------------------------------------------------ [2009-10-23 08:10:25] ed at bellcpa dot com Description: ------------ I have a script that attempts to contact/query an MySQL server on a LAN. If the server is available, the script runs successfully. If the MySQL server is offline, however, the script hangs along with the browser session indefinately. This is despite MYSQLI_OPT_CONNECT_TIMEOUT being set to 5 seconds. Specifically, the script below hangs when "$mysqli->real_connect" is executed Looking for a way to timeout connection attempt. Running VC9 x86 Thread Safe 5.3. Default mysqli/mysqlnd php.ini settings. The code below worked fine in the past in the same scenario on version 5.2.8. Reproduce code: --------------- $mysqli = mysqli_init(); if (!$mysqli) exit(1); if (!$mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 5)) { exit(1); } if (!$mysqli->real_connect('localhost', 'my_user', 'my_password', 'my_db')) { exit(1); } Expected result: ---------------- Quit in around 5 sec with an code 1 if MySQL is offline. Actual result: -------------- Script hangs indefinately and so does a browser session through which the script is invoked. After some time (e.g. 2-5 min) the following is logged in php_errors.log: [23-Oct-2009 00:48:26] PHP Warning: mysqli::real_connect(): [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://192.168.201.222:3306) in C:\app\php\script.php on line 30 [23-Oct-2009 00:48:26] PHP Warning: mysqli::real_connect(): (HY000/2002): A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=49965&edit=1