Phpcurl sets a timeout of 1000 milliseconds (for Intranet requests). Sometimes, timeout exceptions may occur. How can this problem be solved? Php curl sets the timeout time of 1000 milliseconds (for Intranet requests). Sometimes timeout exceptions occur. How can this problem be solved?
Reply content: php curl sets the timeout time of 1000 milliseconds (intranet requests). Sometimes timeout exceptions may occur. How can this problem be solved?
On the PHP side, there is no way to set a larger timeout period. This problem mainly involves optimizing the accessed pages. Since it is an intranet request, the network speed must not be considered. Why does it still time out?
1-The accessed page itself has performance problems: it is usually caused by data search and is optimized (for example, if simple queries do not time out, complex queries will time out );
2-complex page logic, involving a large amount of data: Use cron-job to complete complex logic and cache results, instead of starting processing when receiving the request (for example, obtaining the Sales Report of the last three months in excel format );
3-The requested resource is too large. For example, if the requested content is large and cannot be transmitted within 10 seconds, use the url to transfer the resource content.
I hope this is all I think.
If it is caused by network fluctuations, you can try again and again. For example, if it fails, you can initiate it again until the log is recorded for 10 failed times, and then return the error message to the caller.
One second timeout? I think the timeout is normal.
Since it is an intranet, the speed will be very fast. It is recommended that you do not set the time. Of course, if you are worried that the process is stuck, you can set it to the default value.
Troubleshoot timeout or error log analysis.
You can perform a timeout Retry Mechanism. The specific code for timeout is 7 and 28.