Openssl Ssl_Read: Ssl_Error_Syscall, Errno 104

API causes Curl error: OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054

Based on my test, everything is OK.

My environment:

  1. Windows 10 1809
  2. PHP 7.3 (7.3.11)
  3. cacert from https://curl.haxx.se/ca/cacert.pem

Code:

    $resCurl = curl_init();

$url_API = 'https://example.com/api/someMethod';
$jsonRequest = '{"a":"aaa"}';
curl_setopt( $resCurl, CURLOPT_HTTPHEADER, array( 'Content-type: APPLICATION/JSON; CHARSET=UTF-8' ) );
curl_setopt( $resCurl, CURLOPT_POSTFIELDS, $jsonRequest );

curl_setopt( $resCurl, CURLOPT_POST, true );
curl_setopt( $resCurl, CURLOPT_URL, $url_API );
curl_setopt( $resCurl, CURLOPT_RETURNTRANSFER, 1);

$resultAPI = curl_exec( $resCurl );
$print_r($resultAPI)

Result:

enter image description here


Suggestion

So, basically this part of code is fine.

As you said that it is not related to homestead nor vagrant nor laravel. So, it is most likely a network issue. Maybe you can try to restart the Azure server.


Update

Confirmed by @LatentDenis, he finally found that the problem was caused by the firewall, which can give us a clue to narrow down similiar issues.

Docker compose install error 'curl: (56) OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 104' in Ubuntu

I had the same problem. I assume that you are using Docker Docs, which are usually outdated. You should go to Docker Compose Github instead.

Solution

1 - Open Linux Terminal by pressing Ctrl + Alt + T

2 - Install curl:

sudo apt install curl

3 - Turn on root privileges in terminal for your user (something like admin in Windows OS), with command:

sudo -i

4 - Go to Docker Compose Github. In releases you will find this code. Run it in your linux terminal.

curl -L https://github.com/docker/compose/releases/download/1.25.1-rc1/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose

5 - Turn off root privileges in terminal for your user, with command:

exit

6 - Check if docker-compose is installed with command:

docker-compose version

Outcome: In your terminal, you should see docker-compose version number and some other informations.

PHP Soap issue: OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 54 or SSL: Connection reset by peer

turns out that header value SOAPAction needs to be in extra escaped quote like this:

$headers = [
"SOAPAction: \"http://example-url.com\"",
]

Strange CURL issue with a particular website SSL certificate

The problem is not the certificate of this site. From the debug output it can be clearly seen that the TLS handshake is done successfully and outside this handshake the certificate does not matter.

But, it can be seen that the site www.saiglobal.com is CDN protected by Akamai CDN and Akamai features some kind of bot detection:

$ dig www.saiglobal.com
...
www.saiglobal.com. 45 IN CNAME www.saiglobal.com.edgekey.net.
www.saiglobal.com.edgekey.net. 62 IN CNAME e9158.a.akamaiedge.net.

This bot detection is known to use some heuristics in order to distinguish bots from normal browsers and detection of a bot might result in a status code 403 access denied or in a simple hang of the site - see Scraping attempts getting 403 error or Requests SSL connection timeout.

In this specific case it seems to currently help if some specific HTTP headers are added, specifically Accept-Encoding, Accept-Language, Connection with a value of keep-alive and User-Agent which matches somehow Mozilla. Failure to add these headers or having the wrong values will result in a hang.

The following works currently for me:

$ curl -q -v \
-H "Connection: keep-alive" \
-H "Accept-Encoding: identity" \
-H "Accept-Language: en-US" \
-H "User-Agent: Mozilla/5.0" \
https://www.saiglobal.com/

Note that this deliberately tries to bypass the bot detection. It might stop working if Akamai makes changes to the bot detection.

Please note also that the owner of the site has explicitly enable bot detection for a reason. This means that with deliberately bypassing the detection for your own gain (like providing some service based on scraped information) you might get into legal problems.

error: OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054

I got the answer by some searching on GitHub,

replace this vagrant box add laravel/homestead with

vagrant box add laravel/homestead http://atlas.hashicorp.com/laravel/boxes/homestead


Related Topics



Leave a reply



Submit