curl-library
Re: Connection and Response Timeout for Curl Handle
Date: Wed, 4 Mar 2015 10:33:40 -0500
On Tue, Mar 3, 2015 at 2:42 PM, Praveen Pvs <meetpraveenpvs_at_gmail.com>
wrote:
> Hi,
>
> Please help me to understand these settings for curl handle.
>
> I have set my connection time out to be 10 and response time out to be 10
> secs in my configuration. Following is the code snippet for settings these
> values to the curl handle.
>
> /* Set the connection timeout */
> curl_easy_setopt(locHandle, CURLOPT_CONNECTTIMEOUT, hostDef.conTimeOut);
>
> /* Set the total timeout */
> if(hostDef.respTimeOut > 0)
> {
> curl_easy_setopt(locHandle,
>
> CURLOPT_TIMEOUT,
> hostDef.respTimeOut);
> }
>
> I need to post the data to the server in my application, I am checking the
> behaviour/fallback situation when connection is not available to the host.
>
> I have putoff switch to the outside network to create the host down
> situation
>
> In the logs i have observed that application takes close to 50 secs to
> determine that it is not able to connect to the host. I thought
> CURLOPT_CONNECTTIMEOUT would determine what is the maximum time it should
> wait for the connection check. Is my understanding wrong here??
>
> Please observe the logs of my application below, curl_easy_perform
> function is called at 09:01:58:433 and it returned value 6 at
> 09:02:54:479. it took close to 56 secs. I expect it to take 10 secs since
> conntimeout is set to 10. Am i missing something here?
>
> 03/03/2015 09:01:58:430 0768 793216112 PS: initSSICURLHandle: Url:
> https://x <https://apidemo.ipcharge.net/IPCHAPI/rh.aspx>xxxxxxxxxxxxxxxxx
>
> 03/03/2015 09:01:58:430 0768 793216112 PS: initSSICURLHandle: Url starts
> with https. Cert Validation required
>
> 03/03/2015 09:01:58:431 0768 793216112 PS: initSSICURLHandle: Setting PWC
> URL = [https://apidemo.ipcharge.net/IPCHAPI/rh.aspx]
>
> 03/03/2015 09:01:58:431 0768 793216112 PS: commonInit: --- enter ---
>
> 03/03/2015 09:01:58:431 0768 793216112 PS: commonInit: Url starts with
> https. Doing certificate validation
>
> 03/03/2015 09:01:58:432 0768 793216112 PS: commonInit: --- returning ---
>
> 03/03/2015 09:01:58:432 0768 793216112 PS: initSSICURLHandle: Returning [0]
>
> 03/03/2015 09:01:58:432 0768 793216112 PS: sendDataToHost: --- enter ---
>
> 03/03/2015 09:01:58:433 0768 793216112 PS: initializeRespData: --- enter
> ---
>
> 03/03/2015 09:01:58:433 0768 793216112 PS: initializeRespData: Returning
> [0]
>
> 03/03/2015 09:01:58:433 0768 793216112 PS: sendDataToHost: Posting the
> data to the server
>
> 03/03/2015 09:02:54:479 0768 793216112 PS: sendDataToHost:
> curl_easy_perform done, rv = 6
>
> 03/03/2015 09:02:54:479 0768 793216112 PS: sendDataToHost: Couldnt resolve
> server's address
>
> 03/03/2015 09:02:54:480 0768 793216112 PS: sendDataToHost: Returning [-114]
>
> 03/03/2015 09:02:54:480 0768 793216112 PS: postDataToSSIHost: Failed to
> post data to server
>
>
> Regards
> Praveen
>
Hello Praveen,
I didn't see a response to this, so I will attempt
an
answer:
I am assuming that the timeout options do not apply to the name resolution
phase.
The CURLOPT_TIMEOUT documentation does say "Normally, name lookups can take
a considerable time and limiting operations to less than a few minutes risk
aborting perfectly normal operations." which does imply the name lookup
time is considered
.
However,
it could
indicate
that the lookup time is considered, but that if using blocking DNS the
lookup will not be interrupted if the timeout expires mid-lookup.
It is not clear from the documentation if this is the case.
You could test this theory by specifying an IP address for your host to
avoid the lookup and see if you then get the 10-second connect timeout you
are expecting.
Hopefully somebody more familiar with the internals can confirm or correct.
Regards,
Rich Bramante
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette: http://curl.haxx.se/mail/etiquette.html
Received on 2015-03-04