0

Good day..

I have a web app that makes requests to another server through proxies. Now i would say 99% of these requests works completely fine hand i have no issue what so ever and receive the response back.

However some requests ( again a very few amount ) will return HTTP response code 0, which means curl failed. After debug with curl_error i have collected these 2 errors.

  1. OpenSSL SSL_connect: SSL_ERROR_SYSCALL in connection to URL.
  2. Operation timed out after 7000 milliseconds with 0 out of 0 bytes received

Now the second one is self explanatory. Surely the SSL error is just due to a dodgy proxy otherwise i would get this response with every request and not just 1% ( to the same urls ) ? im pretty sure my curl config is ok. ( below ).

curl_setopt_array($this->ch, array( CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => $url, CURLOPT_FOLLOWLOCATION => 1, CURLOPT_AUTOREFERER => 1, CURLOPT_HTTPHEADER => $headers, CURLOPT_POST => 0, CURLOPT_ENCODING => 'gzip', CURLOPT_HEADER => 0 )); 

Should i just add a curl exec retry if response is nothing / code = 0 ?

Thank you.

2
  • 2
    See if stackoverflow.com/questions/9774349/… helps wil SSL Commented Oct 27, 2018 at 11:09
  • Yes thank you that helps i think CURLOPT_SSL_VERIFYPEER will work just fine. Regards. Commented Oct 27, 2018 at 11:13

1 Answer 1

1

yeah, just retry once or twice, and know that you're not alone, i wrote this some time back:

echo 'file: ' . $file . ' url: ' . $raw_url . '..' . PHP_EOL; try { $headers = implode ( " ", $hc->exec ( $url )->getResponseHeaders () ); } catch ( Exception $ex ) { try { $headers = implode ( " ", $hc->exec ( $url )->getResponseHeaders () ); } catch ( Exception $ex ) { // sometimes connection fails for no good reason, and a retry (or 2) fixes it... // here we give up and deliberately not catch the 3rd exception (if any) $headers = implode ( " ", $hc->exec ( $url )->getResponseHeaders () ); } } 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.