Phpcurl sets a timeout of 1000 milliseconds (for Intranet requests). Sometimes, timeout exceptions may occur. How can this problem be solved?

Source: Internet
Author: User
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.

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.