cURL Error #:Operation timed out after 50007 milliseconds with 30461 out of 272389 bytes received

Viewed 17

case 1

When run php file (http://localhost:8080/Rub_test.php) with below curl implemented code at postman then this error appear cURL Error #:Operation timed out after 50007 milliseconds with 30461 out of 272389 bytes received

When increased CURLOPT_TIMEOUT => 500000 then error not appear but print_r($response); blank show.

case 2

When run only URL with authorization at postman then data show.

https://api.rubiproject.com/analytics/v1/report/?account=publisher%2F11990&start=2022-09-01T00%3A00%3A00-08%3A00&end=2022-09-02T23%3A59%3A59-08%3A00&dimensions=date%2Ccountry%2Csite&metrics=ad_requests%2Cauctions_won%2Cpaid_impression%2Crevenue

please suggest how to get data with curl-php. Or any mistake in curl. please help me.


curl_setopt_array($curl, array(
CURLOPT_URL => "https://api.rubiproject.com/analytics/v1/report/?account=publisher%2F11990&start=2022-09-01T00%3A00%3A00-08%3A00&end=2022-09-02T23%3A59%3A59-08%3A00&dimensions=date%2Ccountry%2Csite&metrics=ad_requests%2Cauctions_won%2Cpaid_impression%2Crevenue",
  CURLOPT_RETURNTRANSFER => true, 
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 50,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "GET",
  CURLOPT_HTTPHEADER => array(
    "authorization: Basic YjA2MzljMzJmYWM0OTA2ssssssssZWNmMjJiZjY0YjljZZWU4NzlkBMGVhMzkxODo0sswwNjk1OTc5YjRlYTaI1NWIyM2Y5NWFlZDE1M2YzODI0Yw==",
    "cache-control: no-cache",
    "content-type: application/json"
  ),
   CURLOPT_FILE => $fp,
  CURLOPT_FOLLOWLOCATION => true
));


$response = curl_exec($curl);
print_r($response);
$err = curl_error($curl);
1 Answers

Make curl timeout like this: CURLOPT_TIMEOUT => 0 to make it infinitely wait for results.

Also, you can read for time out info this

I've tried your code and it gives this error: Could not resolve host: api.rubiproject.com.

To see this error you can use :

  if(curl_errno($curl)){
    echo 'Curl error: ' . curl_error($curl);
}

for more info you can look at here

I suggest that you should check curl info by running this code to see your request's situation.

$info = curl_getinfo($curl, CURLINFO_HTTP_CODE);
Related