instead instead - 1 year ago 132
PHP Question

cURL 35 error when connecting to http website

I couldn't find answer on this questions. Sometimes* while trying to retrieve data from http (NOT https) site I get 35 error - SSL connect error.
URL that I'm trying to reach is ie. Then i get redirected to "full url":

My cURL code:

$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, ''. $id .'.html');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl, CURLOPT_TIMEOUT, 3);
curl_setopt($curl, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.2; WOW64; rv:17.0) Gecko/20100101 Firefox/17.0');
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, 1);
$data = curl_exec($curl);

I've been trying to add
curl_setopt($curl, CURLOPT_SSLVERSION , 3);
but it doesn't help.
Why http site gives a 35 error? Is it normal?
Is it possible that aliexpress i blocking my requests?

Sometimes I also get 28 error which is timeout reached - even with 10 seconds timeout.

*Sometimes - I mean it's working for a few hours then not working for about 10 minutes and then still working.

Answer Source

It looks like you are trying to spider on their site using the Id. And as a consequence the site blocks you. As you are referring to SSL error, it is very likely that during the blockade period they are redirecting you to an error page that starts with https://

For the debugging purpose you can enable the verbose mode and observe the header and you'll find what is inside the Location: response header.

curl_setopt ($curl, CURLOPT_VERBOSE, true);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download