Commit dc37f66792179d8b7eff1e7d6c0280ecdf31953a

Authored by 648540858
Committed by GitHub
2 parents 760b14ea 49a8a08c

Merge pull request #1028 from nikmu/wvp-28181-2.0

捕获启动过程中发送sip异常导致的启动失败
src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java
@@ -4,13 +4,19 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; @@ -4,13 +4,19 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
4 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; 4 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch;
5 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; 5 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
6 import com.genersoft.iot.vmp.service.IPlatformService; 6 import com.genersoft.iot.vmp.service.IPlatformService;
  7 +import com.genersoft.iot.vmp.service.impl.PlatformServiceImpl;
7 import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 8 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
8 import com.genersoft.iot.vmp.storager.IVideoManagerStorage; 9 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
9 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
10 import org.springframework.boot.CommandLineRunner; 13 import org.springframework.boot.CommandLineRunner;
11 import org.springframework.core.annotation.Order; 14 import org.springframework.core.annotation.Order;
12 import org.springframework.stereotype.Component; 15 import org.springframework.stereotype.Component;
13 16
  17 +import javax.sip.InvalidArgumentException;
  18 +import javax.sip.SipException;
  19 +import java.text.ParseException;
14 import java.util.List; 20 import java.util.List;
15 21
16 /** 22 /**
@@ -33,6 +39,7 @@ public class SipPlatformRunner implements CommandLineRunner { @@ -33,6 +39,7 @@ public class SipPlatformRunner implements CommandLineRunner {
33 @Autowired 39 @Autowired
34 private ISIPCommanderForPlatform sipCommanderForPlatform; 40 private ISIPCommanderForPlatform sipCommanderForPlatform;
35 41
  42 + private final static Logger logger = LoggerFactory.getLogger(PlatformServiceImpl.class);
36 43
37 @Override 44 @Override
38 public void run(String... args) throws Exception { 45 public void run(String... args) throws Exception {
@@ -50,9 +57,13 @@ public class SipPlatformRunner implements CommandLineRunner { @@ -50,9 +57,13 @@ public class SipPlatformRunner implements CommandLineRunner {
50 redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); 57 redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch);
51 if (parentPlatformCatchOld != null) { 58 if (parentPlatformCatchOld != null) {
52 // 取消订阅 59 // 取消订阅
53 - sipCommanderForPlatform.unregister(parentPlatform, parentPlatformCatchOld.getSipTransactionInfo(), null, (eventResult)->{  
54 - platformService.login(parentPlatform);  
55 - }); 60 + try {
  61 + sipCommanderForPlatform.unregister(parentPlatform, parentPlatformCatchOld.getSipTransactionInfo(), null, (eventResult)->{
  62 + platformService.login(parentPlatform);
  63 + });
  64 + } catch (InvalidArgumentException | ParseException | SipException e) {
  65 + logger.error("[命令发送失败] 国标级联 注销: {}", e.getMessage());
  66 + }
56 } 67 }
57 68
58 // 设置所有平台离线 69 // 设置所有平台离线
src/main/java/com/genersoft/iot/vmp/gb28181/task/SipRunner.java
@@ -12,13 +12,19 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; @@ -12,13 +12,19 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
12 import com.genersoft.iot.vmp.service.IDeviceService; 12 import com.genersoft.iot.vmp.service.IDeviceService;
13 import com.genersoft.iot.vmp.service.IMediaServerService; 13 import com.genersoft.iot.vmp.service.IMediaServerService;
14 import com.genersoft.iot.vmp.service.IPlatformService; 14 import com.genersoft.iot.vmp.service.IPlatformService;
  15 +import com.genersoft.iot.vmp.service.impl.PlatformServiceImpl;
15 import com.genersoft.iot.vmp.storager.IRedisCatchStorage; 16 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
16 import com.genersoft.iot.vmp.storager.IVideoManagerStorage; 17 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
  18 +import org.slf4j.Logger;
  19 +import org.slf4j.LoggerFactory;
17 import org.springframework.beans.factory.annotation.Autowired; 20 import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.boot.CommandLineRunner; 21 import org.springframework.boot.CommandLineRunner;
19 import org.springframework.core.annotation.Order; 22 import org.springframework.core.annotation.Order;
20 import org.springframework.stereotype.Component; 23 import org.springframework.stereotype.Component;
21 24
  25 +import javax.sip.InvalidArgumentException;
  26 +import javax.sip.SipException;
  27 +import java.text.ParseException;
22 import java.util.HashMap; 28 import java.util.HashMap;
23 import java.util.List; 29 import java.util.List;
24 import java.util.Map; 30 import java.util.Map;
@@ -59,6 +65,8 @@ public class SipRunner implements CommandLineRunner { @@ -59,6 +65,8 @@ public class SipRunner implements CommandLineRunner {
59 @Autowired 65 @Autowired
60 private ISIPCommanderForPlatform commanderForPlatform; 66 private ISIPCommanderForPlatform commanderForPlatform;
61 67
  68 + private final static Logger logger = LoggerFactory.getLogger(PlatformServiceImpl.class);
  69 +
62 @Override 70 @Override
63 public void run(String... args) throws Exception { 71 public void run(String... args) throws Exception {
64 List<Device> deviceList = deviceService.getAllOnlineDevice(); 72 List<Device> deviceList = deviceService.getAllOnlineDevice();
@@ -110,7 +118,11 @@ public class SipRunner implements CommandLineRunner { @@ -110,7 +118,11 @@ public class SipRunner implements CommandLineRunner {
110 if (jsonObject != null && jsonObject.getInteger("code") == 0) { 118 if (jsonObject != null && jsonObject.getInteger("code") == 0) {
111 ParentPlatform platform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId()); 119 ParentPlatform platform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId());
112 if (platform != null) { 120 if (platform != null) {
113 - commanderForPlatform.streamByeCmd(platform, sendRtpItem.getCallId()); 121 + try {
  122 + commanderForPlatform.streamByeCmd(platform, sendRtpItem.getCallId());
  123 + } catch (InvalidArgumentException | ParseException | SipException e) {
  124 + logger.error("[命令发送失败] 国标级联 发送BYE: {}", e.getMessage());
  125 + }
114 } 126 }
115 } 127 }
116 } 128 }