Commit c084d6c98af1ef4d36a61adc719df5db76589428

Authored by 648540858
1 parent 4c28f380

优化国标级联心跳失败判断逻辑

src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java
@@ -203,8 +203,8 @@ public abstract class SIPRequestProcessorParent { @@ -203,8 +203,8 @@ public abstract class SIPRequestProcessorParent {
203 try { 203 try {
204 xml = reader.read(new ByteArrayInputStream(bytesResult)); 204 xml = reader.read(new ByteArrayInputStream(bytesResult));
205 }catch (DocumentException e) { 205 }catch (DocumentException e) {
206 - logger.warn("[xml解析异常]: 愿文如下: \r\n{}", new String(bytesResult));  
207 - logger.warn("[xml解析异常]: 愿文如下: 尝试兼容性处理"); 206 + logger.warn("[xml解析异常]: 原文如下: \r\n{}", new String(bytesResult));
  207 + logger.warn("[xml解析异常]: 原文如下: 尝试兼容性处理");
208 String[] xmlLineArray = new String(bytesResult).split("\\r?\\n"); 208 String[] xmlLineArray = new String(bytesResult).split("\\r?\\n");
209 209
210 // 兼容海康的address字段带有<破换xml结构导致无法解析xml的问题 210 // 兼容海康的address字段带有<破换xml结构导致无法解析xml的问题
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java
@@ -233,19 +233,17 @@ public class PlatformServiceImpl implements IPlatformService { @@ -233,19 +233,17 @@ public class PlatformServiceImpl implements IPlatformService {
233 try { 233 try {
234 commanderForPlatform.keepalive(parentPlatform, eventResult -> { 234 commanderForPlatform.keepalive(parentPlatform, eventResult -> {
235 // 心跳失败 235 // 心跳失败
236 - if (eventResult.type == SipSubscribe.EventResultType.timeout) {  
237 - // 心跳超时  
238 - ParentPlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId());  
239 - // 此时是第三次心跳超时, 平台离线  
240 - if (platformCatch.getKeepAliveReply() == 2) {  
241 - // 设置平台离线,并重新注册  
242 - logger.info("[国标级联] 三次心跳超时, 平台{}({})离线", parentPlatform.getName(), parentPlatform.getServerGBId());  
243 - offline(parentPlatform, false);  
244 - }  
245 -  
246 - }else { 236 + if (eventResult.type != SipSubscribe.EventResultType.timeout) {
247 logger.warn("[国标级联]发送心跳收到错误,code: {}, msg: {}", eventResult.statusCode, eventResult.msg); 237 logger.warn("[国标级联]发送心跳收到错误,code: {}, msg: {}", eventResult.statusCode, eventResult.msg);
248 } 238 }
  239 + // 心跳失败
  240 + ParentPlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId());
  241 + // 此时是第三次心跳超时, 平台离线
  242 + if (platformCatch.getKeepAliveReply() == 2) {
  243 + // 设置平台离线,并重新注册
  244 + logger.info("[国标级联] 三次心跳超时, 平台{}({})离线", parentPlatform.getName(), parentPlatform.getServerGBId());
  245 + offline(parentPlatform, false);
  246 + }
249 247
250 }, eventResult -> { 248 }, eventResult -> {
251 // 心跳成功 249 // 心跳成功