cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: curl does not honor the timeout incase of redirect

From: Rabi Dora <rcdora_at_gmail.com>
Date: Sun, 4 Jan 2015 03:04:23 -0800

Hello Daniel,

Thank you. I tested the latest version 7.39.0 and it honors the timeout.

While testing I found that it honors the timeout value properly only if the
timeout is more than 15ms.
I wrote a simple php page which sleeps 100ms before returning the value.
If I pass CURLOPT_TIMEOUT_MS=2ms, then curl does not honor the timeout and
it takes 100ms. If I set the timeout as 4ms, then the timeout occurs at
8ms, for 8ms the timeout occurs at 12ms. But for all timeout value 15ms
onwards, the timeout occurs at the exact value.

Note all the above case the 'CURLINFO_TOTAL_TIME' shows the proper timeout
value, but the actual timeout (returning from curl_easy_perform) is
different.

For example the output of the program (please check the attachment) for
 CURLOPT_TIMEOUT_MS=2ms
* Hostname was found in DNS cache
* Trying 23.61.194.233...
* Connected to 23.61.194.233 (23.61.194.233) port 80 (#1)
> GET /testsherpa.php HTTP/1.1
Host: 123.61.194.233
Accept: */*

* Operation timed out after 101 milliseconds with 0 bytes received
* Closing connection 1

time elapsed 101604
curl_easy_perform() failed code: 28
curl_easy_perform() failed reason: Timeout was reached
Name lookup time: 0.000058000000000
Name connect time: 0.000335000000000
Name pretransfer time: 0.000387000000000
Name start transfer time: 0.000000000000000
Name total time: 0.001494000000000 /* CURLINFO_TOTAL_TIME value*/
Name redirect time: 0.000000000000000

Attached is the test code for your reference.
Regards,
Rabi

On Wed, Dec 31, 2014 at 10:40 AM, Daniel Stenberg <daniel_at_haxx.se> wrote:
On Tue, 30 Dec 2014, Rabi Dora wrote:

I am using using curl version 7.33 and the libcurl C library ,
curl_easy_perform() function.
The code set the curl timeout to 30ms and follow redirect

But it does NO honor the timeout - incase of the redirect; It follows the
redirect location but if the redirect page takes long time to return, then
it ignores the timeout and wait for the redirect page to return.

I believe this bug was fixed in 7.36.0. Can you please try a recent version
and if it still fails, show us a recipe on how to repdroduce this?

-- 
 / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html


-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html

  • application/octet-stream attachment: simple.cc
Received on 2015-01-04