# GuzzleHttp\Exception\ConnectException：cURL 错误 1：协议 "http2" 不受支持或在 libcurl 中被禁用（请参阅 https://curl.haxx.se/libcurl/c/libcurl-errors.html），位于 /var/www/app/vendor/guzzlehttp/guzzle/src/Handler/CurlFactory.php:187

- **ID:** `php/guzzle-http-version-not-supported`
- **领域:** php
- **类别:** protocol_error
- **错误码:** `1`
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

安装的 libcurl 版本不支持 HTTP/2，但 Guzzle 客户端被配置为使用 'http2' 作为协议版本。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| Guzzle 7.0 | active | — | — |
| Guzzle 7.5 | active | — | — |
| PHP 8.1 | active | — | — |
| PHP 8.2 | active | — | — |

## 解决方案

1. ```
   Downgrade the Guzzle client to use HTTP/1.1 instead: `$client = new GuzzleHttp\Client(['version' => '1.1']);`
   ```
2. ```
   Upgrade libcurl to a version that supports HTTP/2. On Ubuntu/Debian: `sudo apt-get update && sudo apt-get install --only-upgrade libcurl4-openssl-dev` and then recompile PHP's cURL extension. Verify with `php -i | grep cURL` and check 'cURL Information' for HTTP2 support.
   ```

## 无效尝试

- **Setting CURLOPT_HTTP_VERSION to CURL_HTTP_VERSION_2_0 manually in a custom handler** — This does not fix the underlying libcurl limitation; it just changes the constant used, but libcurl still cannot negotiate HTTP/2. (95% 失败率)
- **Reinstalling PHP and cURL extension via apt-get without checking the libcurl version** — The default system libcurl on older OS versions may still lack HTTP/2 support; you need to ensure the libcurl-dev package is from a version that supports HTTP/2 (e.g., >= 7.50.0). (70% 失败率)
