php - curl php HTTP/2 流 0 没有完全关闭

标签 php curl php-curl

我正在尝试使用 cURLPHP 发送请求,但它抛出了一个错误。

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);

cURLcurel_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 吗?任何线索/建议都会有很大的帮助。谢谢。

最佳答案

我遇到了与此类似的问题,我需要检查两件事。

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

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

对我来说,我有协议(protocol) 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

关于php - curl php HTTP/2 流 0 没有完全关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55211579/

相关文章:

php - 此代码在带有保存文件或打开方式的图像查看器中显示图像。其实我想问一下只为用户打开我做什么?

php - 从数据库返回平均评分 (SQL)

php - 在单个查询中获取约会列表并依次获取所有关联的注释?

php - Laravel 4 - 资源 Controller 添加组前缀而不更改路由名称

python - 向 tastypie 发送经过身份验证的 POST 请求

windows - curl 将下载放在哪里?

git - 如何解决[curl : (60) SSL certificate problem: self signed certificate in certificate chain]

php - Laravel 备份错误上传大备份到 s3

php - SagePay API - 创建交易时请求格式不正确 - Php

php - curl_exec 返回什么?