PHP Curl Set 1000 milliseconds time-out (intranet request), sometimes there will be a timeout exception, how to solve?
Reply content:
PHP Curl Set 1000 milliseconds time-out (intranet request), sometimes there will be a timeout exception, how to solve?
There is no alternative to setting a larger time-out on the PHP side, which is primarily about optimizing the page being visited. Since is the intranet request, the network speed certainly does not need to consider, then why also timeout?
1-The page in question has a performance problem: it is usually caused by data search, try to optimize (such as simple query does not time out, complex query timeout);
2-the page is logically complex and involves a large amount of data: Complete complex logic through cron-job and cache the results, rather than starting processing when the request is received (such as obtaining the last 3-month Sales report in Excel format);
3-The requested resource is too large: for example, the content is large, the transmission cannot be completed within 10 seconds, and the delivery URL is used instead of the content of the resource.
That's all I think about, I hope it works.
If simply because of the network fluctuations can be caused by repeated attempts, such as failure to start again, until the failure of 10 times to write down the log, and then return to the caller error message.
A second timeout? Well, I think the timeout is normal.
Since it is the intranet, the speed will be very fast, it is recommended not to set the time, of course, if you are worried about the process card, you can set the default value on the line
Time-out or error logging analysis causes, specifically addressed
You can do the timeout retry mechanism, timeout the specific code you look at, like 7 and 28