Reputation: 4445
I am trying to send a request using cURL
and PHP
and it throws an error.
HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)
I am sending CURLOPT_HTTP_VERSION
like this
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
cURL
info printed with curel_version()
is
Array
(
[version_number] => 475136
[age] => 4
[features] => 11518877
[ssl_version_number] => 0
[version] => 7.64.0
[host] => x86_64-apple-darwin18.2.0
[ssl_version] => OpenSSL/1.0.2q
[libz_version] => 1.2.11
[protocols] => Array
(
[0] => dict
[1] => file
[2] => ftp
[3] => ftps
[4] => gopher
[5] => http
[6] => https
[7] => imap
[8] => imaps
[9] => ldap
[10] => ldaps
[11] => pop3
[12] => pop3s
[13] => rtmp
[14] => rtsp
[15] => scp
[16] => sftp
[17] => smb
[18] => smbs
[19] => smtp
[20] => smtps
[21] => telnet
[22] => tftp
)
[ares] => 1.15.0
[ares_num] => 69376
[libidn] =>
[iconv_ver_num] => 0
[libssh_version] => libssh2/1.8.0
[brotli_ver_num] => 16777223
[brotli_version] => 1.0.7
)
PHP
version: PHP Version => 7.3.2
installed with homebrew
.
I have tried almost all of the solutions here on SO, but still getting the same error. Do I need to download and compile PHP
from source? Any clue/suggestion would be a huge help. Thanks.
Upvotes: 3
Views: 6466
Reputation: 89
I used this code and solve my problem.
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
Upvotes: 0
Reputation: 95
I had a problem similar to this and there was 2 things I needed to check for.
If you're using apache, in /etc/apache2/sites-available/[x].conf look for a line similar to this: Protocols h2 http/1.1
[x] = the name of the website's configuration file such as 00-default
For me I had Protocols h2 https://1.1 and that caused me to have the bug.
Alternative: run this command on your server "grep -ir 'upgrade' /etc/apache2/" Find the file that has the upgrade to http/2 and comment out the line.
This post helped me immensely: https://community.cloudflare.com/t/ssl-causing-website-to-not-load-at-all/39764/30
Upvotes: 1