修改socket连接异常处理

This commit is contained in:
liuhanqing
2025-08-26 17:16:23 +08:00
parent bf59094c3e
commit 51d44d9754
2 changed files with 14 additions and 1 deletions

View File

@@ -52,7 +52,11 @@ public class TagInReadThread implements Runnable {
public void run() {
while (true) {
try (Socket socket = getSocket(ip)) {
if (socket==null){
log.info("电子标签服务器连接失败,请检查ip:{}", ip);
Thread.sleep(5000);
continue;
}
BasTag param = new BasTag();
param.setIp(ip);
param.setSpare3("2");
@@ -131,6 +135,8 @@ public class TagInReadThread implements Runnable {
}
} catch (IOException e) {
log.error(e.getMessage(), e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}

View File

@@ -57,6 +57,11 @@ public class TagOutReadThread implements Runnable {
try (Socket socket = getSocket(ip)) {
//下发标签
if (socket==null){
log.info("电子标签服务器连接失败,请检查ip:{}", ip);
Thread.sleep(5000);
continue;
}
for (Long tagId : collect.keySet()) {
List<TagTask> allTagTasks = collect.get(tagId);
Optional<TagTask> first = allTagTasks.stream().filter(x -> "0".equals(x.getStatus())).findFirst();
@@ -134,6 +139,8 @@ public class TagOutReadThread implements Runnable {
} catch (IOException e) {
throw new RuntimeException(e);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}