easegress icon indicating copy to clipboard operation
easegress copied to clipboard

[Question]: Websocket log expected error

Open cyrnicolase opened this issue 11 months ago • 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.

cyrnicolase avatar Mar 25 '24 02:03 cyrnicolase

			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 https://github.com/nhooyr/websocket/issues/439.

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

suchen-sci avatar Mar 25 '24 03:03 suchen-sci

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

cyrnicolase avatar Apr 01 '24 06:04 cyrnicolase

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 = \"\""}

cyrnicolase avatar Apr 02 '24 03:04 cyrnicolase