fix: ws 处理 Panic 协程异常

This commit is contained in:
TsMask
2024-02-02 17:09:23 +08:00
parent fb7a2dfa3c
commit 1707d9ea3b

View File

@@ -100,6 +100,12 @@ func (s *WSImpl) NewClient(uid string, groupIDs []string, conn *websocket.Conn)
}
}
defer func() {
// 在这里处理 Panic 协程异常
if err := recover(); err != nil {
logger.Errorf("ws Panic Error: %s => %v", clientID, err)
}
}()
go s.clientRead(wsClient)
go s.clientWrite(wsClient)