What is the default time after which an HTTP reque

2019-07-07 08:14发布

问题:

For PHP, what is the default time after which an HTTP request is deemed to have timed out?

I'm using the PECL HTTP extension to make HTTP requests. I can set a timeout limit when making a request, however I'd like to know what the default is if nothing is explicitly specified.

I've hunted through the PHP manual to no avail. I'd appreciate answers supported by evidence, such as a link to the relevant manual page, as opposed to speculative suggestions.

I'm keen to find out what the default timeout actually is not just what it probably is. I can guess it may probably be 30 seconds as this seems a reasonable value, however I can find nothing to confirm or deny this.

回答1:

I'm quite sure what you're looking for is the default_socket_timeout php.ini option. It appears the default is 60 seconds.



回答2:

Just for future reference: http://svn.php.net/viewvc/pecl/http/trunk/http_request_api.c?view=markup

If I understood it correctly, the default timeout options values are:

  • timeout = CURLOPT_TIMEOUT_MS | CURLOPT_TIMEOUT = 0 (means "waits indefinitely")
  • connecttimeout = CURLOPT_CONNECTTIMEOUT_MS | CURLOPT_CONNECTTIMEOUT = 3
  • dns_cache_timeout = CURLOPT_DNS_CACHE_TIMEOUT = 60


标签: php http timeout