Curl not working in php when response size more than 800KB

What is the name of the domain?

ftd.travel

What is the error number?

500 - curl just crashes

What is the error message?

none

What is the issue you’re encountering

Curl does not work in php, when response > 800 kb and throwing 500 error

What steps have you taken to resolve the issue?

Standard curl request does not work when response is over 800kb -
Maybe something similar to PHP CURL issue with long post data - #10 by sandro

I am not able to open support ticket in Cloudflare and don’t know how to proceed as smaller response works absolutely fine. Any other suggestion, otherwise might have to move out of Cloudflare

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_TIMEOUT, 90); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $requestData);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, FALSE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $httpHeader);
    curl_setopt($ch, CURLOPT_ENCODING, "gzip,deflate");

// Execute request, store response and HTTP response code

     $response = curl_exec($ch);
    
    if (curl_errno($ch)) {
		$error_msg = curl_error($ch);
		//print_r($error_msg);die;
	}
    $error = curl_getinfo($ch, CURLINFO_HTTP_CODE);
	curl_close($ch);
    return json_decode($response, true);

What feature, service or problem is this related to?

I don’t know

This is a question for StackOverflow I am afraid. The forum here is only intented for Cloudflare specific issues and a 500 will be sent by your server. You need to debug your code and check if the request is incorrect or if it returns an error, but that is proper good old debugging and only StackOverflow might be able to help here.

It gives error only when the response size is more than 800kb, otherwise works perfectly fine.

So it should not be application error and some config issue. Otherwise it would have failed every time

Sure, but if Cloudflare could not handle such requests, the forum would know :wink:

This will be an issue with your code and that’s what you need to debug I am afraid.

When I disable Cloudflare DNS, it is working fine even for response > 800kb

It is for sure Cloudflare issue - Please check my settings on your end

Well, the 500 won’t be returned by Cloudflare but by your server and that’s what you need to debug. You simply need to check your application and log files.

Again, this won’t be a Cloudflare issue, maybe your server filters IP addresses.

You can certainly post two URLs here to verify your claim, but you will owe me a coffee if it turns out to be an issue with your setup :wink:

2 Likes

Coffee is on us :slight_smile:

Increased time out in php.ini and it solved the issue

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.