ID: 42537 User updated by: sy at yalcin dot us -Summary: fsockopen() hands due to slow firewall/dns response Reported By: sy at yalcin dot us -Status: Feedback +Status: Open Bug Type: URL related Operating System: RHEL 4 PHP Version: 5.2.4 New Comment:
Ok, I will try using gdb to see. It may take a few days to give you feedback. Would strace dump work? Previous Comments: ------------------------------------------------------------------------ [2007-09-04 09:57:36] [EMAIL PROTECTED] Works fine for me. And there is a firewall also between my connection. I think it's your DNS being slow..try debugging this using gdb to see where it hangs. ------------------------------------------------------------------------ [2007-09-03 23:57:15] sy at yalcin dot us 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 this bug report at http://bugs.php.net/?id=42537&edit=1