I have an application which calls RESTful API using CURL POST request. The request is giving desired response if POSTFIELD data is of smaller size (<1024 bytes) but in case of large POSTFIELD the CURL execution only returns "Empty reply from server" error. API script does get executed as I can see only see partial data inserted in my database post which execution terminates abruptly.
I have already tried increasing default_session_timeout and memory_limit.
I checked Apache error logs but did not find anything logged in there as well. This is my code to consume REST API using CURL:
$curl = curl_init($this->serviceUrl);
$curl_post_data = (is_array($data)) ? http_build_query($data) : $data;
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 420);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($curl, CURLOPT_POSTFIELDS, $curl_post_data);
$curl_response = curl_exec($curl);
if ($curl_response === false) {
$errorMessage = curl_error($curl);
$info = curl_getinfo($curl);
\Tools::writeErrorLog($errorMessage);
\Tools::writeErrorLog($info);
}
curl_close($curl);
return $curl_response;
Is there any specific fix for this either in server configuration or the PHP code itself?
PHPINFO Details:
- POST_MAX_SIZE - 8MB
- Memory Limit - 256 MB
- DEFAULT_SOCKET_TIMEOUT - 60