在NGINX后面编写的用Golang编写的HTTP服务器。

huangapple go评论82阅读模式
英文:

http server written in golang behind NGINX

问题

你好,我有一个使用Golang编写的HTTP服务器,它在Nginx后面。对于大多数请求,服务器都正常工作,但有时在POST请求中会出现502错误,而其他时候相同的请求正常工作。
我在Nginx日志中看到以下错误信息:

2021/11/25 12:11:09 [error] 1863330#1863330: *176 sendfile() failed (32: Broken pipe) while sending request to upstream, client: 101.0.53.60, server: cards.bytehack.io, request: "POST /story HTTP/1.1", upstream: "http://127.0.0.1:8081/story", host: "cards.bytehack.io"

我无法确定是什么原因导致了这个错误。希望能得到帮助。

英文:

Hi I have a http server written in golang which is behind nginx. For most of the requests the server works fine but sometimes in POST requests i am getting 502 and other times the same request works fine.
I am getting the following error in nginx logs:

2021/11/25 12:11:09 [error] 1863330#1863330: *176 sendfile() failed (32: Broken pipe) while sending request to upstream, client: 101.0.53.60, server: cards.bytehack.io, request: "POST /story HTTP/1.1", upstream: "http://127.0.0.1:8081/story", host: "cards.bytehack.io"

I am not able to figure out what is causing this error. Any help is appreciated.

答案1

得分: 1

“Broken pipe”消息通常在客户端强制关闭连接时发生。在这种情况下,即使连接已关闭,当HTTP服务器响应时,也会出现“broken pipe”错误(管道错误)。

一些需要注意的主题包括:

  • 连接超时
  • 传输的数据长度过大

请查看这篇文章,它可以引导您得出一些补充性的结论:https://noknow.info/it/go/handling_error_broken_pipe?lang=en

英文:

The "Broken pipe" message usually happens when the connection was forcibly closed in the client side. At that time, when HTTP server responses even though the connection is closed, the "broken pipe" error (pipe error) will come out.

Some topics to look at are:

  • Connection timeout
  • Data length transferred too big

Take a look at this article, it can guide you into some complementary conclusion also: https://noknow.info/it/go/handling_error_broken_pipe?lang=en

huangapple
  • 本文由 发表于 2021年11月25日 20:17:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/70110985.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定