curl php HTTP / 2流0未完全关闭

时间:2019-03-17 20:27:24

标签: php curl php-curl

我正在尝试使用cURLPHP发送请求,但会引发错误。

  

HTTP / 2流0未完全关闭:PROTOCOL_ERROR(错误1)

我正在这样发送CURLOPT_HTTP_VERSION

curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
cURL打印的

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 Version => 7.3.2

已安装homebrew

我在SO上尝试了几乎所有解决方案,但仍然遇到相同的错误。我需要从源代码下载和编译PHP吗?任何线索/建议都会有很大帮助。谢谢。

1 个答案:

答案 0 :(得分:1)

我有一个与此类似的问题,我需要检查两件事。

如果您使用的是apache,请在/etc/apache2/sites-available/[x].conf中查找类似于以下内容的行:Protocols h2 http / 1.1

[x] =网站的配置文件的名称,例如00-default

对我来说,我有协议h2 https://1.1,这使我遇到了错误。

替代: 在您的服务器“ grep -ir'upgrade'/ etc / apache2 /”上运行此命令 找到已升级到http / 2的文件,并在该行中添加注释。

这篇文章极大地帮助了我:https://community.cloudflare.com/t/ssl-causing-website-to-not-load-at-all/39764/30