When the connection interface is slow, the request times out. how can this problem be solved? When the connection interface is slow, the request times out. how can this problem be solved?
Reply content:
When the connection interface is slow, the request times out. how can this problem be solved?
Exception capture.
Recommended class library GuzzleHttp: http://docs.guzzlephp.org/en...
400/500 errors can be captured and processed by yourself.
The network speed is slow and there is no solution. the interface logic can only be optimized as much as possible and timeout processing can be done well.
Initiate a request again based on the returned timeout status. the request has ended more than the specified number of times.
Slow network speed:
Added the timeout setting for curl. if the interface returns an error, run it again.
If the interface does not need to be returned in time, use the queue for processing.
curl_setopt($ch, CURLOPT_TIMEOUT, 600);
// Timeout in milliseconds if the record url times out to log $ timeout_ms = 1000; curl_setopt ($ ch, CURLOPT_TIMEOUT, $ timeout_ms );
If it is a network problem, try modifying the direct interface address of the host file.
If it is a code problem, try to optimize the code,
In addition, it is necessary to set the timeout time reasonably.