获取“curl:(92) HTTP/2 流 1 没有完全关闭:INTERNAL_ERROR (err 2)" [英] Getting "curl: (92) HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2)"
问题描述
我有一个 Django 应用程序,它在调用 API 时返回一个大的 JSON.问题是当我请求数据时,数据本身被截断,导致前端崩溃.
I have a Django app which returns a large JSON while calling an API. The problem is when I'm requesting the data, the data itself is truncated which is crashing the frontend.
我将云前端用于 DNS 和 SSL 以及它们提供的其他功能,用于缓存和提高性能.
I'm using cloud front for DNS and SSL and other feature provided by them for caching and improved performance.
我尝试卷曲 API 并从 curl 中得到以下错误:
I tried curling the API and got the following error from curl:
curl: (92) HTTP/2 流 1 没有完全关闭:INTERNAL_ERROR(错误2)
curl: (92) HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2)
我尝试禁用 Cloudflare,但没有奏效.但是,在我的本地主机上,一切正常.
I tried disabling the Cloudflare but didn't work. On my localhost, however, everything works fine.
HTTP/2 流 1 没有完全关闭:INTERNAL_ERROR (err 2)
HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2)
- 关闭连接 0
- TLSv1.2 (OUT)、TLS 警报、客户端问候 (1):curl:(92) HTTP/2 流 1 未完全关闭:INTERNAL_ERROR (err 2)
JSON 应该被完全获取而不会被分块.
The JSON should be fetched entirely without getting chunked.
推荐答案
我在使用 AWS 的应用程序负载均衡器 (ALB) 时遇到了这个问题.这个问题是我将 Apache 配置为使用 http2,但在 ALB 后面.ALB 默认支持 http2:
I had this issue with AWS's Application Load Balancer (ALB). This issue was that I had Apache configured to use http2, but behind an ALB. The ALB supports http2 by default:
应用程序负载均衡器通过 HTTPS 侦听器为 HTTP/2 提供本机支持.您可以使用一个 HTTP/2 连接并行发送多达 128 个请求.负载均衡器将这些转换为单独的 HTTP/1.1 请求,并将它们分发到目标组中的健康目标.因为 HTTP/2 更有效地使用前端连接,您可能会注意到客户端和负载均衡器之间的连接更少.您不能使用 HTTP/2 的服务器推送功能.1
Application Load Balancers provide native support for HTTP/2 with HTTPS listeners. You can send up to 128 requests in parallel using one HTTP/2 connection. The load balancer converts these to individual HTTP/1.1 requests and distributes them across the healthy targets in the target group. Because HTTP/2 uses front-end connections more efficiently, you might notice fewer connections between clients and the load balancer. You can’t use the server-push feature of HTTP/2. 1
因此,curl 使用 HTTP/2 连接 ALB,然后将其转换为 HTTP/1 请求.Apache 正在向响应添加标头,要求客户端Upgrade
到 HTTP/2,ALB 刚刚将其传递回客户端,并且 curl 将其读取为无效,因为它已经在使用 HTTP/2 连接.我通过在我的 Apache 实例上禁用 HTTP/2 解决了这个问题.由于它将始终位于 ALB 之后,并且 ALB 永远不会使用 HTTP/2,因此使用它没有任何意义.
So, curl was using HTTP/2 to connect with the ALB, which was then converting it into an HTTP/1 request. Apache was adding headers to the response asking the client to Upgrade
to HTTP/2, which the ALB just passed back to the client, and curl read it as invalid since it was already using an HTTP/2 connection. I solved the problem by disabling HTTP/2 on my Apache instance. Since it will always be behind an ALB, and the ALB is never going to make use of HTTP/2, then there is no point of having it.
这篇关于获取“curl:(92) HTTP/2 流 1 没有完全关闭:INTERNAL_ERROR (err 2)"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!