Commit a7f224b1af1e669eda38da867187a148dc993bbb
1 parent
b1511556
修复编码错误
Showing
3 changed files
with
19 additions
and
19 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/SipLayer.java
| ... | ... | @@ -2,22 +2,12 @@ package com.genersoft.iot.vmp.gb28181; |
| 2 | 2 | |
| 3 | 3 | import java.text.ParseException; |
| 4 | 4 | import java.util.Properties; |
| 5 | +import java.util.TooManyListenersException; | |
| 5 | 6 | import java.util.concurrent.LinkedBlockingQueue; |
| 6 | 7 | import java.util.concurrent.ThreadPoolExecutor; |
| 7 | 8 | import java.util.concurrent.TimeUnit; |
| 8 | 9 | |
| 9 | -import javax.sip.DialogTerminatedEvent; | |
| 10 | -import javax.sip.IOExceptionEvent; | |
| 11 | -import javax.sip.ListeningPoint; | |
| 12 | -import javax.sip.PeerUnavailableException; | |
| 13 | -import javax.sip.RequestEvent; | |
| 14 | -import javax.sip.ResponseEvent; | |
| 15 | -import javax.sip.SipFactory; | |
| 16 | -import javax.sip.SipListener; | |
| 17 | -import javax.sip.SipProvider; | |
| 18 | -import javax.sip.SipStack; | |
| 19 | -import javax.sip.TimeoutEvent; | |
| 20 | -import javax.sip.TransactionTerminatedEvent; | |
| 10 | +import javax.sip.*; | |
| 21 | 11 | import javax.sip.message.Response; |
| 22 | 12 | |
| 23 | 13 | import org.slf4j.Logger; |
| ... | ... | @@ -93,11 +83,17 @@ public class SipLayer implements SipListener { |
| 93 | 83 | |
| 94 | 84 | @Bean("tcpSipProvider") |
| 95 | 85 | @DependsOn("sipStack") |
| 96 | - private SipProvider startTcpListener() throws Exception { | |
| 97 | - ListeningPoint tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getSipIp(), sipConfig.getSipPort(), "TCP"); | |
| 98 | - SipProvider tcpSipProvider = sipStack.createSipProvider(tcpListeningPoint); | |
| 99 | - tcpSipProvider.addSipListener(this); | |
| 100 | - logger.info("Sip Server TCP 启动成功 port {" + sipConfig.getSipPort() + "}"); | |
| 86 | + private SipProvider startTcpListener() { | |
| 87 | + ListeningPoint tcpListeningPoint = null; | |
| 88 | + SipProvider tcpSipProvider = null; | |
| 89 | + try { | |
| 90 | + tcpListeningPoint = sipStack.createListeningPoint(sipConfig.getSipIp(), sipConfig.getSipPort(), "TCP"); | |
| 91 | + tcpSipProvider = sipStack.createSipProvider(tcpListeningPoint); | |
| 92 | + tcpSipProvider.addSipListener(this); | |
| 93 | + logger.info("Sip Server TCP 启动成功 port {" + sipConfig.getSipPort() + "}"); | |
| 94 | + } catch (TransportNotSupportedException | InvalidArgumentException | TooManyListenersException | ObjectInUseException e) { | |
| 95 | + logger.error(String.format("创建SIP服务失败: %s", e.getMessage())); | |
| 96 | + } | |
| 101 | 97 | return tcpSipProvider; |
| 102 | 98 | } |
| 103 | 99 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/request/impl/MessageRequestProcessor.java
| ... | ... | @@ -362,7 +362,7 @@ public class MessageRequestProcessor extends SIPRequestAbstractProcessor { |
| 362 | 362 | private Element getRootElement(RequestEvent evt) throws DocumentException { |
| 363 | 363 | Request request = evt.getRequest(); |
| 364 | 364 | SAXReader reader = new SAXReader(); |
| 365 | -// reader.setEncoding("GB2312"); | |
| 365 | + reader.setEncoding("gbk"); | |
| 366 | 366 | Document xml = reader.read(new ByteArrayInputStream(request.getRawContent())); |
| 367 | 367 | return xml.getRootElement(); |
| 368 | 368 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
| ... | ... | @@ -9,6 +9,7 @@ import org.springframework.beans.factory.annotation.Value; |
| 9 | 9 | import org.springframework.stereotype.Component; |
| 10 | 10 | |
| 11 | 11 | import java.io.IOException; |
| 12 | +import java.net.ConnectException; | |
| 12 | 13 | import java.util.HashMap; |
| 13 | 14 | import java.util.HashSet; |
| 14 | 15 | import java.util.Map; |
| ... | ... | @@ -55,7 +56,10 @@ public class ZLMRESTfulUtils { |
| 55 | 56 | responseJSON = JSON.parseObject(responseStr); |
| 56 | 57 | } |
| 57 | 58 | } |
| 58 | - } catch (IOException e) { | |
| 59 | + } catch (ConnectException e) { | |
| 60 | + logger.error(String.format("连接ZLM失败: %s, %s", e.getCause().getMessage(), e.getMessage())); | |
| 61 | + logger.info("请检查media配置并确认ZLM已启动..."); | |
| 62 | + }catch (IOException e) { | |
| 59 | 63 | e.printStackTrace(); |
| 60 | 64 | } |
| 61 | 65 | ... | ... |