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/common/utils/NyHttpUtils.java | 11 ++++++++---
src/main/java/com/zy/core/thread/NyShuttleThread.java | 6 +++---
2 files changed, 11 insertions(+), 6 deletions(-)
diff --git a/src/main/java/com/zy/common/utils/NyHttpUtils.java b/src/main/java/com/zy/common/utils/NyHttpUtils.java
index a049062..be86a96 100644
--- a/src/main/java/com/zy/common/utils/NyHttpUtils.java
+++ b/src/main/java/com/zy/common/utils/NyHttpUtils.java
@@ -313,13 +313,18 @@
JSONObject resultResponse = JSON.parseObject(result.get("response").toString());
JSONObject resultHeader = JSON.parseObject(resultResponse.get("header").toString());
int responseId = Integer.parseInt(resultHeader.get("responseId").toString());
- if (responseId != httpCommand.getRequest().getHeader().getRequestId()) {
- return null;//鍝嶅簲ID涓庤姹侷D涓嶄竴鑷�
- }
+// if (responseId != httpCommand.getRequest().getHeader().getRequestId()) {
+// return null;//鍝嶅簲ID涓庤姹侷D涓嶄竴鑷�
+// }
return filterBodyData(result);//杩斿洖Body缁撴灉闆�
} catch (Exception e) {
e.printStackTrace();
+ try {
+ socket.close();
+ } catch (IOException exception) {
+ exception.printStackTrace();
+ }
}
return null;
}
diff --git a/src/main/java/com/zy/core/thread/NyShuttleThread.java b/src/main/java/com/zy/core/thread/NyShuttleThread.java
index 7ec573f..54e38f7 100644
--- a/src/main/java/com/zy/core/thread/NyShuttleThread.java
+++ b/src/main/java/com/zy/core/thread/NyShuttleThread.java
@@ -87,7 +87,7 @@
private void read() {
try {
- if (this.socket == null || !this.socket.isConnected()) {
+ if (this.socket == null || this.socket.isClosed()) {
//閾炬帴鏂紑閲嶆柊閾炬帴
this.connect();
}
@@ -117,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"));
@@ -243,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()));
}
}
--
Gitblit v1.9.1