ID: 36216 User updated by: ipmax at freesurf dot fr Reported By: ipmax at freesurf dot fr Status: Open Bug Type: Sockets related Operating System: debian PHP Version: 5.1.2 New Comment:
we are talking here of a fsockopen connection attempt to a non responding remote server, like a server with DROP iptable firewall. Noteven responding error or 404, just not responding at all. fsockopen never timeout, fgets never find the EOF. => Hang. Previous Comments: ------------------------------------------------------------------------ [2006-01-31 04:33:20] ipmax at freesurf dot fr This echo "connected," and hangs for ever, timout doesnt works : --------------------------------- $scfp=fsockopen("www.microsoft.com", 111,&$errno,&$errstr,5); if(!$scfp) {echo "error"; exit; } else { echo "connected,"; stream_set_timeout($scfp,2); fputs($scfp,"GET /admin.cgi\r\n\r\n"); while(!feof($scfp)) {$page .= fgets($scfp); } fclose($scfp); ////////////////////// This works, considering timout is checked in the fgets loop. stream_set_timeout() replace the bug of fsockopen that doesnt timeout. $scfp=fsockopen("www.microsoft.com", 111,&$errno,&$errstr,2); if(!$scfp) {echo "error"; exit; } else { echo "connected,"; stream_set_timeout($scfp,2); fputs($scfp,"GET /admin.cgi\r\n\r\n"); while(!feof($scfp)) {$page .= fgets($scfp); $info = stream_get_meta_data($scfp); if ($info['timed_out']) { echo "timeout"; exit; } } fclose($scfp); --------------------- PHP 5.1.1-1.dotdeb.2 (cli) (built: Dec 1 2005 12:46:40) ------------------------------------------------------------------------ [2006-01-30 21:04:03] [EMAIL PROTECTED] >Hello, >i got the bug of fsockopen no timeout >on different debian and latest php >you say it works perfectly, did you tried with a blocked >adress or non existant domain ? Yes, I did. >did you got it to work on debian ? No, since I don't use debian and have no chance to test it there. So if you're able to provide some more information - please provide it. And please use this system instead of mailing privately so we can track the things. ------------------------------------------------------------------------ [2006-01-30 20:47:14] [EMAIL PROTECTED] Not enough information was provided for us to be able to handle this bug. Please re-read the instructions at http://bugs.php.net/how-to-report.php If you can provide more information, feel free to add it to this bug and change the status back to "Open". Thank you for your interest in PHP. Works fine here. ------------------------------------------------------------------------ [2006-01-30 20:29:38] ipmax at freesurf dot fr Description: ------------ fsockopen hang if remote server doesnt reply, like no dns, or server down, or firewall drop paquets. Timeout only works if remote server reply something if a firewall drop paquets, then timeout wont work, and fsockopen hang forever. Same problem on socket_server This is a big problem, that is why many people see theyr script hanging when using fsockopen. I v seen this bug on redhat php 4, and debian php 5 ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=36216&edit=1