PHP: cURL default timeout value

What is the default PHP cURL timeout value? Can I get the value from encoding?

+45
php curl
Apr 25 '12 at 3:22
source share
4 answers

The following values ​​are used by default:

  • CURLOPT_FTP_RESPONSE_TIMEOUT: undefined
  • CURLOPT_TIMEOUT: Undefined
  • CURLOPT_TIMEOUT_MS: Undefined
  • CURLOPT_CONNECTTIMEOUT: 300 seconds
  • CURLOPT_CONNECTTIMEOUT_MS: Undefined
  • CURLOPT_ACCEPTTIMEOUT_MS: 60 seconds

Previous answer (for reference):

I understand that CURL obeys default_socket_timeout unless overridden with CURLOPT_TIMEOUT / CURLOPT_CONNECTTIMEOUT .

 $socket_timeout = ini_get('default_socket_timeout'); // timeout in seconds 
+22
Apr 26 2018-12-12T00:
source share

It depends on what timeout setting you are talking about.

cURL offers various options related to connection timeout settings. Some of these options have a set limit, while others allow you to carry an unlimited amount of time. To understand what the default settings are and which are not, you need to look at the libcurl curl_easy_setopt() function: http://curl.haxx.se/libcurl/c/curl_easy_setopt.html

libcurl lists the following connection timeout settings:

  • CURLOPT_FTP_RESPONSE_TIMEOUT: default (undefined)
  • CURLOPT_TIMEOUT: default (undefined)
  • CURLOPT_TIMEOUT_MS: default (undefined)
  • CURLOPT_CONNECTTIMEOUT: default to 300 seconds
  • CURLOPT_CONNECTTIMEOUT_MS: default
  • CURLOPT_ACCEPTTIMEOUT_MS: default 60,000 ms

The PHP source code does not override any default settings: https://github.com/php/php-src/blob/master/ext/curl/interface.c . The only parameter associated with overriding PHP bindings is CURLOPT_DNS_CACHE_TIMEOUT , changing the default value from 60 seconds to 120 seconds: https://github.com/php/php-src/blob/a0e3ca1c986681d0136ce4550359ecee2826a80cface/cur.face

One answer indicated that PHP would set CURLOPT_TIMEOUT value specified in the default_socket_timeout ini setting. I could not find anything in the PHP source code to back up this application, and I was not able to call the cURL timeout by downloading a very large file with the default_socket_timeout setting for 1 second.

+70
Apr 12 '13 at 23:38
source share
+9
Apr 25 '12 at 5:14
source share

Could it be easier to specify this value directly in the script?

 curl_setopt($curl_handler, CURLOPT_TIMEOUT, 30); // 30 seconds 
-fifteen
Apr 25 '12 at 3:40
source share



All Articles