#38620 [Fbk]: curl_multi_* - timeout after 4-6 socket connects on different hosts
| From: | mike@php.net | Date: | Wed, 06 Sep 2006 12:39:58 +0000 |
| Subject: | #38620 [Fbk]: curl_multi_* - timeout after 4-6 socket connects on different hosts | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-101803@lists.php.net to get a copy of this message | ||
ID: 38620
Updated by: mike@php.net
Reported By: tobsn@php.net
Status: Feedback
Bug Type: cURL related
Operating System: Debian Sarge
PHP Version: 5.1.6
New Comment:
You only set the overall time out; you should also try to set a
reasonable high connect time out.
Previous Comments:
------------------------------------------------------------------------
[2006-09-06 08:13:20] bjori@php.net
Please try using this CVS snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://snaps.php.net/win32/php5.2-win32-latest.zip
------------------------------------------------------------------------
[2006-09-06 07:54:31] tobsn@php.net
<?php
$u[] = 'www.yahoo.com';
$u[] = 'www.flickr.com';
$u[] = 'www.google.com';
$u[] = 'www.digg.com';
$u[] = 'www.shoutwire.com';
$u[] = 'www.example.com';
$u[] = 'www.cnn.com';
$u[] = 'www.ibm.com';
$u[] = 'www.winamp.com';
$u[] = 'www.linkup.com';
$u[] = 'www.nbc.com';
$u[] = 'www.amazon.com';
# uncomment this to test with a single host (should work with no
timeouts in a snap)
# $u = array_fill( 0, 20, 'www.google.com' );
$mh = curl_multi_init();
foreach( $u as $i => $d ) {
$conn[$i] = curl_init( 'http://'.$d );
curl_setopt( $conn[$i], CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $conn[$i], CURLOPT_FOLLOWLOCATION, 1 );//follow
redirects
curl_setopt( $conn[$i], CURLOPT_MAXREDIRS, 1 );//maximum
redirects
curl_setopt( $conn[$i], CURLOPT_USERAGENT,
'Mediapartners-Google/2.1' );
curl_setopt( $conn[$i], CURLOPT_TIMEOUT, 20 );
curl_multi_add_handle( $mh, $conn[$i] );
}
do {
$mrc = curl_multi_exec( $mh, $active );
} while( $mrc == CURLM_CALL_MULTI_PERFORM );
while( $active and $mrc == CURLM_OK ) {
if( curl_multi_select( $mh ) != -1 ) {
do {
$mrc = curl_multi_exec ($mh, $active );
} while( $mrc == CURLM_CALL_MULTI_PERFORM );
}
}
if( $mrc != CURLM_OK ) {
print "Curl multi read error $mrc\n";
}
foreach( $u as $i => $d ) {
echo $i.' - '.$d."\n";
if( ( $err = curl_error( $conn[$i] ) ) == '' ) {
echo 'found something';
}
else {
echo $err."\nnoconnect";
}
echo "\n--\n";
curl_multi_remove_handle( $mh, $conn[$i] );
curl_close( $conn[$i] );
}
curl_multi_close( $mh );
?>
------------------------------------------------------------------------
[2006-09-03 09:20:56] mike@php.net
Complete reproduce code? The multi interface also works fine with
pecl/http.
------------------------------------------------------------------------
[2006-09-02 22:45:37] tobsn@php.net
just btw. the multi interface of libcurl works fine with perl, c (and
cpp).
------------------------------------------------------------------------
[2006-09-02 18:10:16] tobsn@php.net
see in the manual on the php.net/curl_multi_exec, there is the example
code.
trust me, i tested it very hard with everything i know.
because i need this function... so the only workaround for me is to
code a cpp appl, make a perl script or something else but you cant take
php for this. and this sucks.
because the function is there but you cant use it.
i mean it should work. why is there a function that doesnt work...
drives me nuts ;)
------------------------------------------------------------------------
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/38620
--
Edit this bug report at http://bugs.php.net/?id=38620&edit=1