From 6d611bd596f57f0079c36bdb6a7686613f1bbb13 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 04 九月 2023 12:47:15 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/thread/NyShuttleThread.java |   25 ++++++++++++++++++++++++-
 1 files changed, 24 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/zy/core/thread/NyShuttleThread.java b/src/main/java/com/zy/core/thread/NyShuttleThread.java
index 54e38f7..ff5a4df 100644
--- a/src/main/java/com/zy/core/thread/NyShuttleThread.java
+++ b/src/main/java/com/zy/core/thread/NyShuttleThread.java
@@ -244,6 +244,14 @@
         } catch (Exception e) {
             e.printStackTrace();
             OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆戝洓鍚戠┛姊溅Socket鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
+            try {
+                this.socket.close();
+                this.socket = null;
+                Thread.sleep(1000);
+                this.connect();
+            } catch (IOException | InterruptedException exception) {
+                e.printStackTrace();
+            }
         }
     }
 
@@ -254,6 +262,7 @@
             socket.setSoTimeout(60000);
             socket.setKeepAlive(true);
             this.socket = socket;
+            log.info(MessageFormat.format("銆恵0}銆戝洓鍚戠┛姊溅Socket閾炬帴鎴愬姛 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
         } catch (IOException e) {
             OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆戝洓鍚戠┛姊溅Socket閾炬帴澶辫触 ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
         }
@@ -283,7 +292,21 @@
         }
 
         //鍙戝嚭璇锋眰
-        JSONObject result = NyHttpUtils.requestCommand(socket, command);
+        JSONObject result = null;
+        try {
+            result = NyHttpUtils.requestCommand(socket, command);
+        } catch (IOException e) {
+            try {
+                this.socket.close();
+                this.socket = null;
+                Thread.sleep(1000);
+                this.connect();
+            } catch (IOException exception) {
+                exception.printStackTrace();
+            } catch (InterruptedException ex) {
+                throw new RuntimeException(ex);
+            }
+        }
         if (result == null) {
             return false;//璇锋眰澶辫触
         }

--
Gitblit v1.9.1