easegress-io/easegress

[Question]: Websocket log expected error

cyrnicolase opened this issue · 3 comments

The net.ErrClosed maybe an expected error after svrConn.Close(), clntConn.Close().

However, I am now encountering numerous instances of such errors websocketproxy#wsproxy#main: failed to read from client: failed to get reader: use of closed network connection.

			t, m, err := clntConn.Read(stdctx.Background())
			if err != nil {
				if cs := websocket.CloseStatus(err); cs == websocket.StatusNormalClosure {
					svrConn.Close(websocket.StatusNormalClosure, "")
				} else {
					svrConn.Close(cs, err.Error())
					logger.Errorf("%s: failed to read from client: %v", sp.Name, err)
				}
				break
			}

By the code and this issue of our websocket pkg nhooyr/websocket#439.

I think maybe the client side of websocket is not closed by using websocket StatusNormalClosure?

Yes you are right, but I have to accommodate these errors

Me again.

Today I spoke with our iOS development engineers, and after their confirmation, they are using the disconnect() method provided by the SDK, which by default passes websocket.StatusNormalClosure.

And I get websocketproxy#wsproxy#main: failed to read from server: failed to get reader: received close frame: status = StatusNoStatusRcvd and reason = ""

And when I use apifox test it, I get {"level":"ERROR","time":"2024-04-02T03:24:58.978Z","caller":"httpproxy/wspool.go:285","message":"websocketproxy#wsproxy#main: failed to read from server: failed to get reader: received close frame: status = StatusNoStatusRcvd and reason = \"\""}, {"level":"ERROR","time":"2024-04-02T03:24:58.979Z","caller":"httpproxy/wspool.go:257","message":"websocketproxy#wsproxy#main: failed to read from client: failed to get reader: received close frame: status = StatusNoStatusRcvd and reason = \"\""}