fix(websocket): 增强 WebSocket 会话关闭时的错误处理
- 在 CsWsClientManager 中记录会话关闭失败的日志 - 在 CsWsServer 的 onClose 方法中添加异常日志记录 - 替换忽略异常的注释为具体的错误日志输出
This commit is contained in:
+1
@@ -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;
|
||||
|
||||
+1
-1
@@ -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);
|
||||
|
||||
+2
-2
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user