得到"curl:(92)HTTP/2流1没有被彻底关闭:INTERNAL_ERROR(err 2)".在请求大数据时 [英] Getting "curl: (92) HTTP/2 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2)" while requesting large data

查看:108
本文介绍了得到"curl:(92)HTTP/2流1没有被彻底关闭: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.

我正在将Cloud Front用于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 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 stream 1 was not closed cleanly: INTERNAL_ERROR (err 2)
* Closing connection 0
* TLSv1.2 (OUT), TLS alert, Client hello (1):
curl: (92) HTTP/2 stream 1 was not closed cleanly: 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

因此,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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆