From a82b831b8b2b96dfa5791808f1207500e16697cf Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期三, 04 一月 2023 10:39:40 +0800
Subject: [PATCH] 优化设备状态保持,自动记录心跳间隔,三次心跳失败则设备离线,不在使用设备有效期字段作为唯一判断标准,提高容错能力和稳定性。

---
 src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java
index 5c31f90..f3fbbb4 100644
--- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java
+++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/SipUtils.java
@@ -121,6 +121,12 @@
         return builder.toString();
     }
 
+    /**
+     * 浠庤姹備腑鑾峰彇璁惧ip鍦板潃鍜岀鍙e彿
+     * @param request 璇锋眰
+     * @param sipUseSourceIpAsRemoteAddress  false 浠巚ia涓幏鍙栧湴鍧�锛� true 鐩存帴鑾峰彇杩滅▼鍦板潃
+     * @return 鍦板潃淇℃伅
+     */
     public static RemoteAddressInfo getRemoteAddressFromRequest(SIPRequest request, boolean sipUseSourceIpAsRemoteAddress) {
 
         String remoteAddress;
@@ -132,11 +138,11 @@
             // 鍒ゆ柇RPort鏄惁鏀瑰彉锛屾敼鍙樺垯璇存槑璺敱nat淇℃伅鍙樺寲锛屼慨鏀硅澶囦俊鎭�
             // 鑾峰彇鍒伴�氫俊鍦板潃绛変俊鎭�
             remoteAddress = request.getTopmostViaHeader().getReceived();
-            remotePort = request.getTopmostViaHeader().getPort();
+            remotePort = request.getTopmostViaHeader().getRPort();
             // 瑙f瀽鏈湴鍦板潃鏇夸唬
             if (ObjectUtils.isEmpty(remoteAddress) || remotePort == -1) {
-                remoteAddress = request.getViaHost();
-                remotePort = request.getViaPort();
+                remoteAddress = request.getTopmostViaHeader().getHost();
+                remotePort = request.getTopmostViaHeader().getPort();
             }
         }
 

--
Gitblit v1.8.0