#50553 [Bgs]: Multiple curl_exec and curl_close looses host
| From: | jani@php.net | Date: | Tue, 22 Dec 2009 08:58:42 +0000 |
| Subject: | #50553 [Bgs]: Multiple curl_exec and curl_close looses host | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-146018@lists.php.net to get a copy of this message | ||
ID: 50553
Updated by: jani@php.net
Reported By: levi_tedder at hotmail dot com
Status: Bogus
Bug Type: cURL related
Operating System: Windows XP, Windows 2003
PHP Version: 5.2.12
New Comment:
Whatever is happening happens in curl, so ask support there, not here.
But basically what you're doing: Just DO NOT do that. If you need to do
that, you're either doing something nasty or don't really know what
you're doing.
Previous Comments:
------------------------------------------------------------------------
[2009-12-22 08:58:13] jani@php.net
Whatever is happening happens in curl, so ask support there, not here.
But basically what you're doing: Just DO NOT do that. If you need to do
that, you're either doing something nasty or don't really know what
you're doing.
------------------------------------------------------------------------
[2009-12-22 08:00:48] levi_tedder at hotmail dot com
Description:
------------
If you have a web server host that responds very quickly and you're
doing a lot of requests on it, curl will eventually respond "couldn't
connect to host". This happens on my Windows XP machine and Windows 2003
server, but I've been unable to reproduce on Windows 2008. If I add a
delay with usleep(50000) it seems to be ok.
I'm not sure if this is by design, OS-restriction or wrong usage (I've
tried forums) or actual bug. Please forgive misplacement.
To get the script below to exit with "couldn't connect to host" you
need a fast responding web server host.
Reproduce code:
---------------
<?php
$url = "http://www.example.com";
for ($i = 1; $i <= 6000; $i++) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$result=curl_exec ($ch);
if (curl_errno($ch)) {
exit(curl_error($ch));
} else {
curl_close($ch);
echo "count: $i\n";
}
}
?>
Expected result:
----------------
count: 1
.
.
count: 6000
Actual result:
--------------
count: 1
.
.
count 4322
couldn't connect to host
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=50553&edit=1