curl php HTTP / 2流0未完全关闭 [英] curl php HTTP/2 stream 0 was not closed cleanly
问题描述
我正在尝试使用 cURL
和 PHP
发送请求,并引发错误。
I am trying to send a request using cURL
and PHP
and it throws an error.
HTTP / 2流0没有干净关闭:PROTOCOL_ERROR(err 1)
HTTP/2 stream 0 was not closed cleanly: PROTOCOL_ERROR (err 1)
我正在发送 CURLOPT_HTTP_VERSION
这样的
curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
cURL
打印有<$ c $的信息c> curel_version()是
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
版本: PHP版本=> 7.3.2
已安装 homebrew
。
我在SO上尝试了几乎所有解决方案,但是仍然遇到相同的错误。我是否需要从源代码下载并编译 PHP
?任何线索/建议都会有很大帮助。谢谢。
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.
推荐答案
我遇到了类似的问题,需要检查两件事。
I had a problem similar to this and there was 2 things I needed to check for.
如果您使用的是apache,请在/etc/apache2/sites-available/[x].conf中查找类似于以下内容的行:Protocols h2 http / 1.1
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] =网站配置文件的名称,例如00-默认值
[x] = the name of the website's configuration file such as 00-default
对我来说,我有Protocols h2 https://1.1 ,这导致我遇到了这个错误。
For me I had Protocols h2 https://1.1 and that caused me to have the bug.
替代:
在服务器上运行此命令 grep -ir升级 / etc / apache2 /
查找已升级到http / 2的文件并注释掉该行。
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.
这篇文章极大地帮助了我: https://community.cloudflare.com/t/ssl-causing-website- to-not-load-at-all / 39764/30
This post helped me immensely: https://community.cloudflare.com/t/ssl-causing-website-to-not-load-at-all/39764/30
这篇关于curl php HTTP / 2流0未完全关闭的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!