may i consult this to you.. So This is my settings for every curl request i made..
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');
}
It works fine but in some scenarios it returns null response after 10 seconds.. But my timeout I set is actually 60 seconds as you see..
Logger:
//Works fine execution time : 3 sec
2017-12-06 09:08:48:06963100 => [3B07B7743F4EAD58CD] CURL Request: {{json data}}
2017-12-06 09:08:51:69533700 => [3B07B7743F4EAD58CD] CURL Response: {{json data}}
//Error.. Returning null after 10 sec
2017-12-06 08:51:35:74268300 => [F1461F1921E49ED226] CURL Request: {{json data}}
2017-12-06 08:51:45:94968500 => [F1461F1921E49ED226] CURL Response: null