Commit dc37f66792179d8b7eff1e7d6c0280ecdf31953a
Committed by
GitHub
Merge pull request #1028 from nikmu/wvp-28181-2.0
捕获启动过程中发送sip异常导致的启动失败
Showing
2 changed files
with
27 additions
and
4 deletions
src/main/java/com/genersoft/iot/vmp/conf/SipPlatformRunner.java
| ... | ... | @@ -4,13 +4,19 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 4 | 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; |
| 5 | 5 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| 6 | 6 | import com.genersoft.iot.vmp.service.IPlatformService; |
| 7 | +import com.genersoft.iot.vmp.service.impl.PlatformServiceImpl; | |
| 7 | 8 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 8 | 9 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 10 | +import org.slf4j.Logger; | |
| 11 | +import org.slf4j.LoggerFactory; | |
| 9 | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | 13 | import org.springframework.boot.CommandLineRunner; |
| 11 | 14 | import org.springframework.core.annotation.Order; |
| 12 | 15 | import org.springframework.stereotype.Component; |
| 13 | 16 | |
| 17 | +import javax.sip.InvalidArgumentException; | |
| 18 | +import javax.sip.SipException; | |
| 19 | +import java.text.ParseException; | |
| 14 | 20 | import java.util.List; |
| 15 | 21 | |
| 16 | 22 | /** |
| ... | ... | @@ -33,6 +39,7 @@ public class SipPlatformRunner implements CommandLineRunner { |
| 33 | 39 | @Autowired |
| 34 | 40 | private ISIPCommanderForPlatform sipCommanderForPlatform; |
| 35 | 41 | |
| 42 | + private final static Logger logger = LoggerFactory.getLogger(PlatformServiceImpl.class); | |
| 36 | 43 | |
| 37 | 44 | @Override |
| 38 | 45 | public void run(String... args) throws Exception { |
| ... | ... | @@ -50,9 +57,13 @@ public class SipPlatformRunner implements CommandLineRunner { |
| 50 | 57 | redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); |
| 51 | 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 | 12 | import com.genersoft.iot.vmp.service.IDeviceService; |
| 13 | 13 | import com.genersoft.iot.vmp.service.IMediaServerService; |
| 14 | 14 | import com.genersoft.iot.vmp.service.IPlatformService; |
| 15 | +import com.genersoft.iot.vmp.service.impl.PlatformServiceImpl; | |
| 15 | 16 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 16 | 17 | import com.genersoft.iot.vmp.storager.IVideoManagerStorage; |
| 18 | +import org.slf4j.Logger; | |
| 19 | +import org.slf4j.LoggerFactory; | |
| 17 | 20 | import org.springframework.beans.factory.annotation.Autowired; |
| 18 | 21 | import org.springframework.boot.CommandLineRunner; |
| 19 | 22 | import org.springframework.core.annotation.Order; |
| 20 | 23 | import org.springframework.stereotype.Component; |
| 21 | 24 | |
| 25 | +import javax.sip.InvalidArgumentException; | |
| 26 | +import javax.sip.SipException; | |
| 27 | +import java.text.ParseException; | |
| 22 | 28 | import java.util.HashMap; |
| 23 | 29 | import java.util.List; |
| 24 | 30 | import java.util.Map; |
| ... | ... | @@ -59,6 +65,8 @@ public class SipRunner implements CommandLineRunner { |
| 59 | 65 | @Autowired |
| 60 | 66 | private ISIPCommanderForPlatform commanderForPlatform; |
| 61 | 67 | |
| 68 | + private final static Logger logger = LoggerFactory.getLogger(PlatformServiceImpl.class); | |
| 69 | + | |
| 62 | 70 | @Override |
| 63 | 71 | public void run(String... args) throws Exception { |
| 64 | 72 | List<Device> deviceList = deviceService.getAllOnlineDevice(); |
| ... | ... | @@ -110,7 +118,11 @@ public class SipRunner implements CommandLineRunner { |
| 110 | 118 | if (jsonObject != null && jsonObject.getInteger("code") == 0) { |
| 111 | 119 | ParentPlatform platform = platformService.queryPlatformByServerGBId(sendRtpItem.getPlatformId()); |
| 112 | 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 | } | ... | ... |