fix(websocket): 增强 WebSocket 会话关闭时的错误处理

- 在 CsWsClientManager 中记录会话关闭失败的日志
- 在 CsWsServer 的 onClose 方法中添加异常日志记录
- 替换忽略异常的注释为具体的错误日志输出
This commit is contained in:
2025-10-27 15:11:10 +08:00
parent 9492dd5e43
commit 33b47da464
3 changed files with 4 additions and 3 deletions
@@ -31,6 +31,7 @@ import org.springframework.http.converter.StringHttpMessageConverter;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@@ -48,7 +48,7 @@ public class CsWsClientManager {
// log.info("关闭session, sid={}", sid);
wsServer.getSession().close();
} catch (Exception e) {
// ignore
log.error("Close session failed, sid={}", sid, e);
}
// log.info("停止任务, sid={}", sid);
wsServer.stopTask(sid);
@@ -76,7 +76,7 @@ public class CsWsServer {
try {
CsWsClientManager.removeClient(this.sid);
} catch (Exception e) {
// ignore
log.error("WebSocket onClose error, sid={}", this.sid, e);
}
}
@@ -86,7 +86,7 @@ public class CsWsServer {
try {
CsWsClientManager.removeClient(this.sid);
} catch (Exception e) {
// ignore
log.error("WebSocket onClose error, sid={}", this.sid, e);
}
}