我可以向您咨询..所以这是我对每个卷曲请求的设置..
try{
$ch = curl_init();
if(strtoupper($method) == "POST" && $setParamsforPOST == true){
$body = json_encode($body);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $body );
}
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $curlUrl);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 60);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$httpcode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$data_curl = curl_exec($ch);
curl_close($ch);
return $data_curl;
}catch(Exception $e){
echo "An Error Has Encountered";
header('X-PHP-Response-Code: 500', TRUE, '500');
}
它工作正常但在某些情况下它会在10秒后返回null响应..但是我设置的超时实际上是60秒,如你所见..
记录器:
//工作时间很短:3秒
2017-12-06 09:08:48:06963100 => [3B07B7743F4EAD58CD] CURL请求:{{json data}}
2017-12-06 09:08:51:69533700 => [3B07B7743F4EAD58CD] CURL响应:{{json data}}
//错误.. 10秒后返回null
2017-12-06 08:51:35:74268300 => [F1461F1921E49ED226] CURL请求:{{json data}}
2017-12-06 08:51:45:94968500 => [F1461F1921E49ED226] CURL响应:null