From 4a349f04abb665c0e99930bc1ef1c54ef24614f7 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期一, 04 九月 2023 08:43:41 +0800
Subject: [PATCH] #

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

diff --git a/src/main/java/com/zy/core/thread/NyShuttleThread.java b/src/main/java/com/zy/core/thread/NyShuttleThread.java
index 3d3d8a0..54e38f7 100644
--- a/src/main/java/com/zy/core/thread/NyShuttleThread.java
+++ b/src/main/java/com/zy/core/thread/NyShuttleThread.java
@@ -87,6 +87,10 @@
 
     private void read() {
         try {
+            if (this.socket == null || this.socket.isClosed()) {
+                //閾炬帴鏂紑閲嶆柊閾炬帴
+                this.connect();
+            }
             readStatus();
             //鍥涘悜绌挎杞︾┖闂层�佹湁浠诲姟銆佹爣璁颁负true銆佸瓨鍦ㄤ换鍔℃寚浠わ紝闇�瑕佹墽琛屼换鍔$殑涓嬩竴鏉℃寚浠�
             if (shuttleProtocol.getFree() == ShuttleStatusType.IDLE.id
@@ -113,7 +117,7 @@
             NyShuttleHttpCommand readStatusCommand = NyHttpUtils.getReadStatusCommand(slave.getId());
             JSONObject jsonObject = NyHttpUtils.requestCommand(socket, readStatusCommand);
             if (jsonObject == null) {
-                OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆戝洓鍚戠┛姊溅plc鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
+                OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆戝洓鍚戠┛姊溅Socket鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
             }else {
                 //鎵嬪姩鐘舵��/鑷姩鐘舵��
                 shuttleProtocol.setWorkingMode(jsonObject.getInteger("workingMode"));
@@ -239,7 +243,7 @@
             }
         } catch (Exception e) {
             e.printStackTrace();
-            OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆戝洓鍚戠┛姊溅plc鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
+            OutputQueue.SHUTTLE.offer(MessageFormat.format("銆恵0}銆戝洓鍚戠┛姊溅Socket鐘舵�佷俊鎭け璐� ===>> [id:{1}] [ip:{2}] [port:{3}]", DateUtils.convert(new Date()), slave.getId(), slave.getIp(), slave.getPort()));
         }
     }
 
@@ -248,6 +252,7 @@
         try {
             Socket socket = new Socket(slave.getIp(),slave.getPort());
             socket.setSoTimeout(60000);
+            socket.setKeepAlive(true);
             this.socket = socket;
         } 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()));

--
Gitblit v1.9.1