#50553 [Bgs]: Multiple curl_exec and curl_close looses host

From: Date: Tue, 22 Dec 2009 10:43:45 +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-146023@lists.php.net to get a copy of this message
 ID:               50553
 User updated by:  levi_tedder at hotmail dot com
 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:

What are you talking about? Where is "there"? I'm using PHP and post a
thing here.
I'm doing what I'm doing because there's a service running on a server
that needs to be contacted this way (a http get request).
If I have a lot of simultaneous heavy usage (which is extremely
common), the example script below will show what happens. Why wouldn't I
do this then?


Previous Comments:
------------------------------------------------------------------------

[2009-12-22 08:58:41] 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



Thread (1 message)

  • levi_tedder at hotmail dot com
  • Unknown Message
    • levi_tedder at hotmail dot com
« previous php.bugs (#146023) next »