fix: ws 处理 Panic 协程异常

This commit is contained in:
TsMask committed 2024-02-02 17:09:23 +08:00
1 parent fb7a2dfa3c
commit 1707d9ea3b
1 file changed
+6
+6
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)