PHP CURL service calls a third-party interface to set the timeout period
#If you do not set the connection timeout time and waiting timeout time
PHP uses curl to develop the habit of setting timeout time, most of the online PHP Curl code is not set
- Reptile business: will block the process, especially when accessing foreign resources
- Business interface: Affect the user experience, need to set the timeout time according to the business, and record the error log for feedback to the relevant personnel after the specified time
#Suggest
- Develop good habits
- If you use PHP to generate CURL extensions, it is best to package a composer yourself
- Use third-party libraries, such as
guzzlehttp/guzzle
, most authors will set a default time
#PHP CURL timeout parameter
//Connection timeout
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
//Wait for response timeout, choose one of two
curl_setopt($ch, CURLOPT_TIMEOUT, 10); //second level
curl_setopt($ch, CURLOPT_TIMEOUT_MS, 10);//millisecond level
#Support Author
Did you enjoyed the article ?