From: sy at yalcin dot us Operating system: RHEL 4 PHP version: 5.2.4 PHP Bug Type: URL related Bug description: fsockopen() hands due to slow firewall/dns response
Description: ------------ Firewall blocking or slowness in DNS causes fsockopen() hang, much more than it should.This should return in 2 seconds. But it does not: somedomain.localsite is not valid. php -a Interactive mode enabled <?php echo time()."\n"; $f = fsockopen('somedomain.localsite', 80, $tmp, $tmp, 2); echo time()."\n"; var_dump($f); 1188857394 1188857426 bool(false) Try with a unreachable IP, it returns as expected: (10.20.30.40 is not valid) php -a Interactive mode enabled <?php echo time()."\n"; $f = fsockopen('10.20.30.40', 80, $tmp, $tmp, 2); echo time()."\n"; var_dump($f); 1188857495 1188857497 bool(false) This can be a firewall/dns issue. There is a very complicated firewall installed here, which I don't know details yet. It seems some packages are received, so that function does not time out as expected. However it does not return because it waits for some other packages. Following is a google connection, it connects, but still not within 2 seconds. Socket handler is returned as if there is no delay! php -a Interactive mode enabled <?php echo time()."\n"; $f = fsockopen('www.google.com', 80, $tmp, $tmp, 2); echo time()."\n"; var_dump($f); 1188857665 1188857681 resource(1) of type (stream) Reproduce code: --------------- Tested this with PHP 5.2.3 and does the same problem. PHP is compiled with this: ./configure \ --with-config-file-path=/etc \ --enable-bcmath \ --with-bz2 \ --enable-calendar \ --enable-ftp \ --with-gettext \ --with-iconv \ --enable-mbstring=all \ --with-mysql \ --with-openssl \ --enable-sockets \ --enable-wddx \ --with-zlib \ --with-xmlrpc \ --enable-soap \ --enable-pcntl \ --enable-memory-limit \ --enable-force-cgi-redirect \ --disable-debug \ --enable-cgi \ --enable-fastcgi \ --enable-sysvsem \ --enable-sysvshm \ --enable-sysvmsg \ --enable-shmop \ --with-apxs2 Expected result: ---------------- I expect that fsockopen() will return back witin 2 seconds: 1) with FALSE return, means unsuccessful, 2) with a valid socket handler. Any delay more than 2 seconds is not acceptable. -- Edit bug report at http://bugs.php.net/?id=42537&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=42537&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=42537&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=42537&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=42537&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=42537&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=42537&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=42537&r=needscript Try newer version: http://bugs.php.net/fix.php?id=42537&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=42537&r=support Expected behavior: http://bugs.php.net/fix.php?id=42537&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=42537&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=42537&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=42537&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=42537&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=42537&r=dst IIS Stability: http://bugs.php.net/fix.php?id=42537&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=42537&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=42537&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=42537&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=42537&r=mysqlcfg