Quellcode durchsuchen

更新 websocket-client 掉线重连

reghao vor 2 Jahren
Ursprung
Commit
751b849885

+ 4 - 10
agent/src/main/java/cn/reghao/devops/agent/event/ws/WebSocketListenerImpl.java

@@ -59,16 +59,10 @@ public class WebSocketListenerImpl extends WebSocketListener {
 
     @Override
     public void onFailure(WebSocket webSocket, Throwable throwable, Response response) {
-        log.info("WebSocket 异常事件: {}", throwable.toString());
-        if (throwable instanceof ConnectException
-                || throwable instanceof EOFException
-                || throwable instanceof ProtocolException) {
-            wsClient.setConnected(false);
-            if (wsClient.isRetry()) {
-                reconnect();
-            }
-        } else {
-            throwable.printStackTrace();
+        log.info("WebSocket 异常事件: {}", throwable.getMessage());
+        wsClient.setConnected(false);
+        if (wsClient.isRetry()) {
+            reconnect();
         }
     }