cURL
Haxx ad
libcurl

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-tracker mailing list Archives

[ curl-Bugs-3061535 ] CURLOPT_TIMEOUT

From: SourceForge.net <noreply_at_sourceforge.net>
Date: Wed, 08 Sep 2010 20:48:21 +0000

Bugs item #3061535, was opened at 2010-09-07 15:05
Message generated for change (Comment added) made by rodricg
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=3061535&group_id=976

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: http
Group: wrong behaviour
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Rodric Glaser (rodricg)
Assigned to: Daniel Stenberg (bagder)
Summary: CURLOPT_TIMEOUT

Initial Comment:
Curl will not abort the operation until <connect time> + CURLOPT_TIMEOUT.

Testing this is a bit involved. I am using:
- The attached multi.php script which hits http://127.0.0.1:82/
- http://127.0.0.1:82/index.php which just sleeps
- The delay-net.pl from http://people.redhat.com/berrange/notes/network-delay.html with a 1.5 second delay
- To delay the initial connect the rule: iptables -I INPUT -i lo -p tcp -m tcp --dport 82 --syn -j QUEUE

Running multi.php then results in:
>php -f "multi.php"
Resource id #5: 28 (Operation timed out after 2000 milliseconds with 0 bytes received)
TotalTime: 3.5011 seconds

I gather this is not the expected behavior based on http://curl.haxx.se/mail/lib-2010-06/0087.html

I have yet to test this with a non php client (my c is rusty) but I have seen the same behavior with:
- curl 7.19.7 (ubuntu php)
- curl 7.20.1 (sabayon php)
- curl 7.21.1 (manual compile)

----------------------------------------------------------------------

>Comment By: Rodric Glaser (rodricg)
Date: 2010-09-08 13:48

Message:
np, my comment confused matters. I had curl_multi on my mind and I
completely overlooked the obvious solution to remove php from the mix...
just use curl :)

It appears that dns lookup time is also not included in the timeout.

Using the same setup (minus multi.php) and adding:
- a 127.0.0.1 DNS entry for loopback.han
- a dns lookup delay with: iptables -A OUTPUT -o eth0 -p udp --dport 53 -m
string --algo bm --string 'loopback' -j QUEUE

and then using the hostname:

# date ; time /opt/usr/bin/curl -v --trace-time --connect-timeout 4
--max-time 5 http://loopback.han:82/
Wed Sep 8 13:28:26 PDT 2010
13:28:27.759020 * About to connect() to loopback.han port 82 (#0)
13:28:27.759097 * Trying 127.0.0.1... connected
13:28:29.260180 * Connected to loopback.han (127.0.0.1) port 82 (#0)
13:28:29.260250 > GET / HTTP/1.1
13:28:29.260250 > User-Agent: curl/7.21.1 (x86_64-unknown-linux-gnu)
libcurl/7.21.1 OpenSSL/0.9.8m zlib/1.2.5 libidn/1.18 libssh2/1.2.2
13:28:29.260250 > Host: loopback.han:82
13:28:29.260250 > Accept: */*
13:28:29.260250 >
13:28:34.261411 * Operation timed out after 5001 milliseconds with 0 bytes
received
13:28:34.261451 * Closing connection #0
curl: (28) Operation timed out after 5001 milliseconds with 0 bytes
received

real 0m8.008s
user 0m0.000s
sys 0m0.003s

My primary goal was a reliable way to test overall connection timeouts
(for multiple pieces of software) ie. I'm not anxiously awaiting a fix ;)
However, I do use curl all the time and find it invaluable Thanks for all
your hard work!

----------------------------------------------------------------------

Comment By: Daniel Stenberg (bagder)
Date: 2010-09-08 00:35

Message:
man if I could just read the description properly I would've realized that
you indeed added time to the connection phase, sorry, but I'll stop
spamming this with stupid comments now and instead try to find some time to
work on this issue. I'll get back in a day or two I hope.

----------------------------------------------------------------------

Comment By: Daniel Stenberg (bagder)
Date: 2010-09-08 00:32

Message:
I've updated the summary since this clearly is not the connect time you see
added. Connecting to localhost is done in milliseconds.

----------------------------------------------------------------------

Comment By: Rodric Glaser (rodricg)
Date: 2010-09-07 15:49

Message:
Silly me, its much easier to use:

time curl http://127.0.0.1:82/ --connect-timeout 3 --max-time 4
curl: (28) Operation timed out after 4000 milliseconds with 0 bytes
received

real 0m5.511s
user 0m0.000s
sys 0m0.010s

----------------------------------------------------------------------

You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=100976&aid=3061535&group_id=976
Received on 2010-09-08

These mail archives are generated by hypermail.

donate! Page updated November 12, 2010.
web site info

File upload with ASP.NET