From 4c28f380aa454ce741173a369fb87fa1554c9388 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sat, 7 Oct 2023 14:52:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96byte=E6=95=B0=E7=BB=84?= =?UTF-8?q?=E8=BD=AC=E6=8D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 6 ++++++ .../transmit/event/request/SIPRequestProcessorParent.java | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pom.xml b/pom.xml index 2ecfad30..9899d275 100644 --- a/pom.xml +++ b/pom.xml @@ -207,6 +207,12 @@ 2.1.3 + + com.google.guava + guava + 20.0 + + com.alibaba.fastjson2 diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java index d52f4f6a..2b7424a6 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.transmit.SIPSender; import com.genersoft.iot.vmp.gb28181.utils.SipUtils; +import com.google.common.primitives.Bytes; import gov.nist.javax.sip.message.SIPRequest; import gov.nist.javax.sip.message.SIPResponse; import org.apache.commons.lang3.ArrayUtils; @@ -196,8 +197,7 @@ public abstract class SIPRequestProcessorParent { result.add(rawContent[i]); } } - Byte[] bytes = new Byte[0]; - byte[] bytesResult = ArrayUtils.toPrimitive(result.toArray(bytes)); + byte[] bytesResult = Bytes.toArray(result); Document xml; try { From c084d6c98af1ef4d36a61adc719df5db76589428 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sat, 7 Oct 2023 18:00:08 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BD=E6=A0=87?= =?UTF-8?q?=E7=BA=A7=E8=81=94=E5=BF=83=E8=B7=B3=E5=A4=B1=E8=B4=A5=E5=88=A4?= =?UTF-8?q?=E6=96=AD=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../request/SIPRequestProcessorParent.java | 4 ++-- .../vmp/service/impl/PlatformServiceImpl.java | 20 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java index 2b7424a6..d983d410 100755 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/SIPRequestProcessorParent.java +++ b/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的问题 diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java index b67fcc5b..f3b4fc90 100755 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformServiceImpl.java +++ b/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 -> { // 心跳成功