Do not log as error on connection reset by peer (#1923)

This commit is contained in:
Raja Subramanian
2023-08-01 19:04:54 +05:30
committed by GitHub
parent a595c09bd2
commit db3fbb57ae

View File

@@ -361,8 +361,16 @@ func (s *RTCService) ServeHTTP(w http.ResponseWriter, r *http.Request) {
req, count, err := sigConn.ReadRequest()
if err != nil {
// normal/expected closure
if err == io.EOF || strings.HasSuffix(err.Error(), "use of closed network connection") ||
websocket.IsCloseError(err, websocket.CloseAbnormalClosure, websocket.CloseGoingAway, websocket.CloseNormalClosure, websocket.CloseNoStatusReceived) {
if err == io.EOF ||
strings.HasSuffix(err.Error(), "use of closed network connection") ||
strings.HasSuffix(err.Error(), "connection reset by peer") ||
websocket.IsCloseError(
err,
websocket.CloseAbnormalClosure,
websocket.CloseGoingAway,
websocket.CloseNormalClosure,
websocket.CloseNoStatusReceived,
) {
pLogger.Infow("exit ws read loop for closed connection", "connID", cr.ConnectionID, "wsError", err)
} else {
pLogger.Errorw("error reading from websocket", err, "connID", cr.ConnectionID)