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.
CodePudding user response:
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