Why twist to ignore CURLOPT_TIMEOUT_MS (but to honor CURLOPT_TIMEOUT)?

I use curl to call the web service API. The service may not respond, so I want to set a timeout. When I use CURLOPT_TIMEOUT everything works as expected. But when I use CURLOPT_TIMEOUT_MS (note the "MS" in milliseconds), the timeout does not appear at all. php.net tells me that the latter was available with PHP version 5.2.3, and I am using 5.2.6.

Any ideas why this is happening?

Thanks.

Code snippet:

$c = curl_init(); curl_setopt( $c, CURLOPT_URL, $call ); curl_setopt( $c, CURLOPT_HTTPHEADER, $headers); curl_setopt( $c, CURLOPT_HEADER, false ); curl_setopt( $c, CURLOPT_RETURNTRANSFER, true ); curl_setopt( $c, CURLOPT_TIMEOUT_MS, 100 ); curl_setopt( $c, CURLOPT_CONNECTIONTIMEOUT_MS, 100 ); $result = curl_exec($c); curl_close($c); 
+4
source share
2 answers

To close this question:

The curl version used by me (7.15.5) does not support CURLOPT_TIMEOUT_MS. According to Greg, I need at least 7.16.2.

+7
source

I have observed a similar problem on a CentOS 5.4 system running curl version 4.3.0, and it seems that whenever curl is created using the "standard system name resolver", this behavior manifests itself.

The workaround is to use the "CURLOPT_NOSIGNAL" option along with "CURLOPT_TIMEOUT_MS"; However, this may have consequences.

Check the details on the following page: https://ravidhavlesha.wordpress.com/2012/01/08/curl-timeout-problem-and-solution/

0
source

All Articles