|
|
|
@ -49,11 +49,9 @@ public class TCPClient { |
|
|
|
for (EquipmentFolderLocation config : serverConfigs) { |
|
|
|
executorService.submit(() -> connectAndRead(config)); |
|
|
|
// 为每个设备配置一个定时任务,定期检测连接状态 |
|
|
|
if (false){ |
|
|
|
scheduler.scheduleWithFixedDelay(() -> { |
|
|
|
checkConnection(config); |
|
|
|
}, CHECK_INTERVAL, CHECK_INTERVAL, TimeUnit.SECONDS); |
|
|
|
} |
|
|
|
scheduler.scheduleWithFixedDelay(() -> { |
|
|
|
checkConnection(config); |
|
|
|
}, CHECK_INTERVAL, CHECK_INTERVAL, TimeUnit.SECONDS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -98,6 +96,7 @@ public class TCPClient { |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
log.error("连接设备失败或读取数据时发生错误, IP: {}, Port: {}", config.getIp(), config.getPort(), e); |
|
|
|
closeConnection(key); |
|
|
|
} finally { |
|
|
|
try { |
|
|
|
if (in != null) { |
|
|
|
|