优化级联时的异常处理

This commit is contained in:
panlinlin
2021-04-26 18:38:57 +08:00
parent bc2b288547
commit 39078225f1
25 changed files with 226 additions and 31 deletions

View File

@@ -43,7 +43,7 @@ public class CheckForAllRecordsThread extends Thread {
if (totalRecordList.size() < this.recordInfo.getSumNum()) {
logger.info("已获取" + totalRecordList.size() + "项录像数据,共" + this.recordInfo.getSumNum() + "");
} else {
logger.info("录像数据已全部获取,共" + this.recordInfo.getSumNum() + "");
logger.info("录像数据已全部获取,共 {} 项", this.recordInfo.getSumNum());
this.recordInfo.setRecordList(totalRecordList);
for (int i = 0; i < cacheKeys.size(); i++) {
redis.del(cacheKeys.get(i).toString());

View File

@@ -58,6 +58,7 @@ public class ByeRequestProcessor extends SIPRequestAbstractProcessor {
param.put("vhost","__defaultVhost__");
param.put("app",sendRtpItem.getApp());
param.put("stream",streamId);
param.put("ssrc",sendRtpItem.getSsrc());
logger.info("停止向上级推流:" + streamId);
zlmrtpServerFactory.stopSendRtpStream(param);
redisCatchStorage.deleteSendRTPServer(platformGbId, channelId);

View File

@@ -93,6 +93,11 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
GbStream gbStream = storager.queryStreamInParentPlatform(requesterId, channelId);
// 不是通道可能是直播流
if (channel != null || gbStream != null ) {
if (channel.getStatus() == 0) {
logger.info("通道离线返回400");
responseAck(evt, Response.BAD_REQUEST, "channel [" + channel.getChannelId() + "] offline");
return;
}
responseAck(evt, Response.CALL_IS_BEING_FORWARDED); // 通道存在发181呼叫转接中
}else {
logger.info("通道不存在返回404");
@@ -367,6 +372,12 @@ public class InviteRequestProcessor extends SIPRequestAbstractProcessor {
getServerTransaction(evt).sendResponse(response);
}
private void responseAck(RequestEvent evt, int statusCode, String msg) throws SipException, InvalidArgumentException, ParseException {
Response response = getMessageFactory().createResponse(statusCode, evt.getRequest());
response.setReasonPhrase(msg);
getServerTransaction(evt).sendResponse(response);
}
/**
* 回复带sdp的200
* @param evt

View File

@@ -770,14 +770,17 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor {
try {
Element rootElement = getRootElement(evt);
String deviceId = XmlUtil.getText(rootElement, "DeviceID");
// 检查设备是否存在, 不存在则不回复
if (storager.exists(deviceId)) {
Device device = storager.queryVideoDevice(deviceId);
// 检查设备是否存在并在线, 不存在则不回复
if (device != null && device.getOnline() == 1) {
// 回复200 OK
responseAck(evt);
if (offLineDetector.isOnline(deviceId)) {
publisher.onlineEventPublish(deviceId, VideoManagerConstants.EVENT_ONLINE_KEEPLIVE);
} else {
}
}else {
logger.warn("收到[ "+deviceId+" ]心跳信息, 但是设备" + (device == null? "不存在":"离线") + ", 心跳信息不予以回复");
}
} catch (ParseException | SipException | InvalidArgumentException | DocumentException e) {
e.printStackTrace();

View File

@@ -146,7 +146,7 @@ public class RegisterRequestProcessor extends SIPRequestAbstractProcessor {
// 注册成功
// 保存到redis
// 下发catelog查询目录
if (registerFlag == 1 && device != null) {
if (registerFlag == 1 ) {
logger.info("注册成功! deviceId:" + device.getDeviceId());
// boolean exists = storager.exists(device.getDeviceId());
device.setRegisterTimeMillis(System.currentTimeMillis());

View File

@@ -80,12 +80,13 @@ public class RegisterResponseProcessor implements ISIPResponseProcessor {
// 注册/注销成功
logger.info(String.format("%s %s成功", platformGBId, action));
redisCatchStorage.delPlatformRegisterInfo(callId);
parentPlatform.setStatus(true);
parentPlatform.setStatus("注册".equals(action));
// 取回Expires设置避免注销过程中被置为0
ParentPlatform parentPlatformTmp = storager.queryParentPlatByServerGBId(platformGBId);
String expires = parentPlatformTmp.getExpires();
parentPlatform.setExpires(expires);
storager.updateParentPlatform(parentPlatform);
parentPlatform.setId(parentPlatformTmp.getId());
storager.updateParentPlatformStatus(platformGBId, "注册".equals(action));
redisCatchStorage.updatePlatformRegister(parentPlatform);