PHP Curl Timeout problem

Source: Internet
Author: User
Tags nginx server

Debugging a very old code today found Nginx server timeout changed the Nginx configuration

The discovery is that the background script has been waiting for troubleshooting until the last discovery was caused by a curl timeout

Specific solutions:

curl_setopt ($this->ch, Curlopt_url, $url);
curl_setopt ($this->ch, Curlopt_returntransfer, 1);
curl_setopt ($this->ch, curlopt_timeout_ms,3000); 3-second timeout
curl_setopt ($this->ch, Curlopt_header, 0);
curl_setopt ($this->ch, Curlopt_ssl_verifypeer, false);
curl_setopt ($this->ch, Curlopt_ssl_verifyhost, false);

PHP Curl Time-out of the main 4 parameters of the original text as follows;

There ' s a very distinctive difference between these, configurations within CURL. I ' ll try to define them for you, and then provide you a very common example which I share to people who I teach about CURL .

Curlopt_connecttimeoutis designed to tell the script how long to wait for make a successful connection to the server before starting to buffer th E output. A destination ' s server which may is overloaded, offline or crashed would probably make this setting become useful.

Curlopt_timeoutis designed-to-tell the script, a long to wait-to-receive a completely buffered output from the server. A destination ' s huge file, slow connection speeds or slow rendering would probably make this setting become.

A Good example of where these would both apply to, was when you ' re telling cURL to download a MP3 file. Curlopt_connecttimeout would be set on about ten seconds which would mean that if No. response is provided within Then the script would abort, and Curlopt_timeout would be set at about seconds which would mean if the MP3 have not Dow nloaded within seconds then abort the script. It's the best-of-the-explaining it to developers.

The specific is:

Curlopt_connecttimeout

Time-out settings when establishing a connection

Curlopt_timeout

Time-out setting when receiving information

Curlopt_connecttimeout_ms, Curlopt_timeout_ms means the same as just the timeout unit for milliseconds ...

PHP Curl Timeout problem

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.