Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GuzzleHttp RequestException - cURL error 56: OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 #2131

Closed
jtheodas opened this issue Aug 28, 2018 · 8 comments
Labels
lifecycle/stale No activity for a long time

Comments

@jtheodas
Copy link

I'm getting this error when I make a request to a particular website (https://www.retailchoice.com).
I'm using Guzzle from the Symfony framework.
So when I execute this code:
$this->crawler = $this->client->request('GET', "https://www.retailchoice.com/");

I get this error:

PHP Fatal error: Uncaught exception 'GuzzleHttp\Exception\RequestException' with message 'cURL error 56: OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 (see http://curl.haxx.se/libcurl/c/libcurl-errors.html)' in D:\Data\xampp5.6.34\xampp\ehjdata\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php:186
Stack trace:
#0 D:\Data\xampp5.6.34\xampp\ehjdata\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(149): GuzzleHttp\Handler\CurlFactory::createRejection(Object(GuzzleHttp\Handler\EasyHandle), Array)
#1 D:\Data\xampp5.6.34\xampp\ehjdata\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php(102): GuzzleHttp\Handler\CurlFactory::finishError(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#2 D:\Data\xampp5.6.34\xampp\ehjdata\vendor\guzzlehttp\guzzle\src\Handler\CurlHandler.php(43): GuzzleHttp\Handler\CurlFactory::finish(Object(GuzzleHttp\Handler\CurlHandler), Object(GuzzleHttp\Handler\EasyHandle), Object(GuzzleHttp\Handler\CurlFactory))
#3 D:\Data\xampp5.6.3 in D:\Data\xampp5.6.34\xampp\ehjdata\vendor\guzzlehttp\guzzle\src\Handler\CurlFactory.php on line 186

I turned on debug & caught the RequestException & here is the print out:

  • Trying 104.116.47.229...
  • TCP_NODELAY set
  • Connected to www.retailchoice.com (104.116.47.229) port 443 (#0)
  • ALPN, offering http/1.1
  • Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@strength
  • successfully set certificate verify locations:
  • CAfile: D:\Data\xampp5.6.34\xampp\apache\bin\curl-ca-bundle.crt
    CApath: none
  • SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
  • ALPN, server accepted to use http/1.1
  • Server certificate:
  • subject: C=BE; L=Bruxelles; O=StepStone SA; CN=www.totaljobs.com
  • start date: Apr 9 00:00:00 2018 GMT
  • expire date: Nov 2 12:00:00 2018 GMT
  • subjectAltName: host "www.retailchoice.com" matched cert's "www.retailchoice.com"
  • issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=GeoTrust RSA CA 2018
  • SSL certificate verify ok.

GET / HTTP/1.1
host: www.retailchoice.com
user-agent: Symfony BrowserKit

  • OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054
  • Closing connection 0
    GET / HTTP/1.1
    user-agent: Symfony BrowserKit
    host: www.retailchoice.com

Array
(
[errno] => 56
[error] => OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054
[url] => https://www.retailchoice.com/
[content_type] =>
[http_code] => 0
[header_size] => 0
[request_size] => 78
[filetime] => -1
[ssl_verify_result] => 0
[redirect_count] => 0
[total_time] => 20.766
[namelookup_time] => 0.266
[connect_time] => 0.266
[pretransfer_time] => 1.86
[size_upload] => 0
[size_download] => 0
[speed_download] => 0
[speed_upload] => 0
[download_content_length] => -1
[upload_content_length] => -1
[starttransfer_time] => 0
[redirect_time] => 0
[redirect_url] =>
[primary_ip] => 104.116.47.229
[certinfo] => Array
(
)

[primary_port] => 443
[local_ip] => 192.168.0.101
[local_port] => 51174

)

I don't have issues when I try other websites. Just this one. What should I do to solve this? Thank you.

@hondnl
Copy link

hondnl commented Nov 20, 2018

Would it have anything to do with the HTTP buffer size ?

https://curl.haxx.se/libcurl/c/CURLOPT_BUFFERSIZE.html

Did you try to play with it ?

new Client([
'curl.options' =>[ 'CURLOPT_BUFFERSIZE' =>'somethingL']
]);

@inferiore
Copy link

was it solved? It's happening me in some cases

@steefaan
Copy link

I would be also interested in an answer.

@jtheodas
Copy link
Author

jtheodas commented May 24, 2019

I have no idea if it has been solved. This is how I worked around this issue.

$this->crawler = $this->myRequest($feed_url);

private function myRequest($feed_url) {
        $html = file_get_contents($feed_url); //get the html returned from the following url
        $domdoc = new DOMDocument(); 
        //$basehref = null;   
        libxml_use_internal_errors(TRUE); //disable libxml errors
        if(!empty($html)) { //if any html is actually returned    
            $domdoc->loadHTML($html);
            libxml_clear_errors(); //remove errors for yucky html
            if (strrpos($feed_url, "?")>0) {
                $arr = explode("?", $feed_url, 2);
                $basehref = $arr[0];
            } else {
                $basehref = $feed_url;
            }
            return new Crawler($domdoc->cloneNode(true), $feed_url, $basehref);
        } else {
            return null;
        }
    }

@scorp13
Copy link

scorp13 commented Oct 24, 2019

It seems that this site is using anti-scraping protection. You could try to change user-agent header.

@gmponos
Copy link
Member

gmponos commented Dec 29, 2019

Please read this:

http://docs.guzzlephp.org/en/stable/request-options.html#verify

Also try (for testing purposes) to set verify to false and check if this works. Not sure how to do that from symfony. Let me know the result.

@stale
Copy link

stale bot commented Sep 25, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 2 weeks if no further activity occurs. Thank you for your contributions.

@stale stale bot added the lifecycle/stale No activity for a long time label Sep 25, 2020
@stale stale bot closed this as completed Oct 9, 2020
@amirgee007
Copy link

I have no idea if it has been solved. This is how I worked around this issue.

$this->crawler = $this->myRequest($feed_url);

private function myRequest($feed_url) {
        $html = file_get_contents($feed_url); //get the html returned from the following url
        $domdoc = new DOMDocument(); 
        //$basehref = null;   
        libxml_use_internal_errors(TRUE); //disable libxml errors
        if(!empty($html)) { //if any html is actually returned    
            $domdoc->loadHTML($html);
            libxml_clear_errors(); //remove errors for yucky html
            if (strrpos($feed_url, "?")>0) {
                $arr = explode("?", $feed_url, 2);
                $basehref = $arr[0];
            } else {
                $basehref = $feed_url;
            }
            return new Crawler($domdoc->cloneNode(true), $feed_url, $basehref);
        } else {
            return null;
        }
    }

it works for me.

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/stale No activity for a long time
Projects
None yet
Development

No branches or pull requests

7 participants