Request CUrl does not work depending on JSON size

0

My problem is that depending on the size of the JSON sent, the CUrl request does not work, that is, if I send 2 photos in JSON , of course, 4 is already reason for TimeOut .

The problem is not in API because in Postman it works regardless of the size of JSON , that is, I think it's some configuration I'm not setting, does anyone have any idea?

CUrl Framework ...

$ch = curl_init();

curl_setopt_array($ch, array(
            CURLOPT_URL => trim($this->vg['url'] . $url1 . $url2),
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_ENCODING => "",
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 30,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => $method,
            CURLOPT_POSTFIELDS => $json,
            CURLOPT_HTTPHEADER => array(
              "Cache-control: no-cache",
              "Accept: application/json",
              "Content-type: application/json",
            ),
          ));
    
asked by anonymous 29.05.2018 / 19:09

1 answer

0

The cURL timeout is in 30s, change the line below:

CURLOPT_TIMEOUT => 30

for (1800 = 30min):

CURLOPT_TIMEOUT => 1800

Source: link

Also put the code below first. Note: 30 * 60 = 1800s = 30min maximum timeout (maximum execution time). And post_max_size tb has an influence on uploading files, according to the php documentation.

ini_set('max_execution_time', 30*60);
ini_set('post_max_size','256M');

Source: link

    
29.05.2018 / 19:36