[英]Nest.js API + Google Cloud Storage on Cloud Run every GET request to trigger "Stream error in the HTTP/2 framing layer" (POST requests work fine)
I created a Nest.js API service that has an endpoint to upload a file to a Google Bucket.我创建了一个 Nest.js API 服务,它有一个端点可以将文件上传到 Google Bucket。 Everything works perfectly locally and also when using the local Docker image.
在本地以及使用本地 Docker 图像时,一切都完美无缺。 Once I deploy (successfully) on Cloud Run, all GET requests return "Error: Stream error in the HTTP/2 framing layer" from Insomnia.
一旦我在 Cloud Run 上部署(成功),所有 GET 请求都会从 Insomnia 返回“错误:HTTP/2 框架层中的 Stream 错误”。 The rest of the endpoints (POST, etc.) works perfectly.
端点(POST 等)的 rest 工作正常。 I thought it was because I was using streams.
我以为是因为我在使用流。 Therefore, I switched to normal file upload, but it did not help.
因此,我切换到正常的文件上传,但没有帮助。
I am not using HTTP/2 in Nest.js and I do not need it.我没有在 Nest.js 中使用 HTTP/2,也不需要它。 I just need to upload a small file through the API.
我只需要通过API上传一个小文件。
I tried enabling HTTP/2 on Cloud Run.我尝试在 Cloud Run 上启用 HTTP/2。 Did not help.
没有帮助。 I remove the stream implementation and use the normal "upload".
我删除了 stream 实现并使用正常的“上传”。 Did not help.
没有帮助。
Could you please suggest a course of action?你能建议一个行动方案吗?
This error often appears when a server has HTTP/2 support however there is an intermediate reverse proxy that doesn't completely support HTTP/2 responses by the backend.当服务器支持 HTTP/2 但存在不完全支持后端 HTTP/2 响应的中间反向代理时,通常会出现此错误。 So the client and server negotiate an upgrade to HTTP/2, but in between the get expression breaks things.
因此,客户端和服务器协商升级到 HTTP/2,但在 get 表达式之间破坏了一些东西。 Also the http/2 is always preferred when supported by both client and server.
此外,当客户端和服务器都支持时,http/2 始终是首选。 To avoid this error,you can try to disable it using below:
为避免此错误,您可以尝试使用以下方法禁用它:
handle_setopt(http_version = 2) (2 is the value for CURL_HTTP_VERSION_1_1)
Cloud Run is an HTTP Request/Response design. Cloud Run 是一个 HTTP 请求/响应设计。 This means that processing starts when you call the endpoint and ends when the endpoint returns.There is also a possibility as some APIs configurations and calling methods don't seem compatible with the latest HTTP version.
这意味着处理在您调用端点时开始,在端点返回时结束。也有可能是某些 API 配置和调用方法似乎与最新的 HTTP 版本不兼容。 The newer version of CURL will use this protocol by default and as a result will fail.
较新版本的 CURL 将默认使用此协议,因此会失败。 This can create some rather confusing behavior because a script that works on one machine may not necessarily work on another by default means what is used unless you set another version.
这可能会产生一些相当混乱的行为,因为在一台机器上运行的脚本可能不一定在另一台机器上运行,默认情况下意味着使用什么,除非您设置另一个版本。 Thus, setting 1_1 as the protocol version required will override the default libcurl itself would use.
因此,将 1_1 设置为所需的协议版本将覆盖默认的 libcurl 本身将使用的版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.