Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cURL: Operation timed out after 0 milliseconds

Tags:

php

curl

cURL gives me the error:

Operation timed out after 0 milliseconds with 0 out of 0 bytes received

In particular, the "0 milliseconds" part is suspicious...

My initialization code:

$curl = curl_init($requestUrl); // private URL not published
curl_setopt($curl, CURLOPT_FRESH_CONNECT, true);
curl_setopt($curl, CURLINFO_HEADER_OUT, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($curl, CURLOPT_HTTPHEADER, 
  array("Content-Type: application/xml", "Accept: application/xml"));
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_TIMEOUT, 20);
curl_setopt($curl, CURLOPT_FAILONERROR, false);
curl_setopt($curl, CURLOPT_HTTP200ALIASES, range(400, 599));
curl_setopt($curl, CURLOPT_SSLVERSION, 3);
curl_setopt($curl, CURLOPT_POST, 1);
curl_setopt($curl, CURLOPT_POSTFIELDS, $data);

The timeout seems correctly set, what may be related it?

like image 329
madbob Avatar asked Mar 18 '14 16:03

madbob


People also ask

What is cURL error?

cURL errors are often caused by an outdated version of PHP or cURL. cURL errors are a good example of server-related errors. These are errors that aren't caused by WordPress or Really Simple SSL, but by a server configuration. These errors usually won't cause any issues on the front end of your site.


1 Answers

I had the same issue, when tried to connect via https. Problem was with ssl version. This worked well for me:

$ch=curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSLVERSION, 3);
like image 120
Chehuzz Avatar answered Sep 22 '22 12:09

Chehuzz