浏览代码

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

648540858 2 年之前
父节点
当前提交
c084d6c98a

+ 2 - 2
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java

@@ -203,8 +203,8 @@ public abstract class SIPRequestProcessorParent {
 		try {
 			xml = reader.read(new ByteArrayInputStream(bytesResult));
 		}catch (DocumentException e) {
-			logger.warn("[xml解析异常]: 文如下: \r\n{}", new String(bytesResult));
-			logger.warn("[xml解析异常]: 文如下: 尝试兼容性处理");
+			logger.warn("[xml解析异常]: 文如下: \r\n{}", new String(bytesResult));
+			logger.warn("[xml解析异常]: 文如下: 尝试兼容性处理");
 			String[] xmlLineArray = new String(bytesResult).split("\\r?\\n");
 
 			// 兼容海康的address字段带有<破换xml结构导致无法解析xml的问题

+ 9 - 11
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java

@@ -233,19 +233,17 @@ public class PlatformServiceImpl implements IPlatformService {
                         try {
                             commanderForPlatform.keepalive(parentPlatform, eventResult -> {
                                 // 心跳失败
-                                if (eventResult.type == SipSubscribe.EventResultType.timeout) {
-                                    // 心跳超时
-                                    ParentPlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId());
-                                    // 此时是第三次心跳超时, 平台离线
-                                    if (platformCatch.getKeepAliveReply()  == 2) {
-                                        // 设置平台离线,并重新注册
-                                        logger.info("[国标级联] 三次心跳超时, 平台{}({})离线", parentPlatform.getName(), parentPlatform.getServerGBId());
-                                        offline(parentPlatform, false);
-                                    }
-
-                                }else {
+                                if (eventResult.type != SipSubscribe.EventResultType.timeout) {
                                     logger.warn("[国标级联]发送心跳收到错误,code: {}, msg: {}", eventResult.statusCode, eventResult.msg);
                                 }
+                                // 心跳失败
+                                ParentPlatformCatch platformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId());
+                                // 此时是第三次心跳超时, 平台离线
+                                if (platformCatch.getKeepAliveReply()  == 2) {
+                                    // 设置平台离线,并重新注册
+                                    logger.info("[国标级联] 三次心跳超时, 平台{}({})离线", parentPlatform.getName(), parentPlatform.getServerGBId());
+                                    offline(parentPlatform, false);
+                                }
 
                             }, eventResult -> {
                                 // 心跳成功