我正在尝试使用 Mobicents/Restcomm sip-servlets 做一个简单的 B2BUA 应用程序。首先,它应该收到一个邀请,更改 R-URI 并发送新请求 - 基本上是呼叫转移。
我遇到的问题是,当使用带有域名而不是 IP 的 URI 时,我收到以下错误:
Unexpected exception while processing message INVITE sip:dispatcher@kam.ims SIP/2.0
...........
org.mobicents.servlet.sip.core.DispatcherException: An unexpected IO exception occured while routing the following initial request INVITE sip:dispatcher@kam.ims SIP/2.0
at org.mobicents.servlet.sip.core.dispatchers.InitialRequestDispatcher$InitialDispatchTask.dispatch(InitialRequestDispatcher.java:753) [sip-servlets-impl-3.1.633.jar:3.1.633]
at org.mobicents.servlet.sip.core.dispatchers.DispatchTask.dispatchAndHandleExceptions(DispatchTask.java:58) [sip-servlets-impl-3.1.633.jar:3.1.633]
at org.mobicents.servlet.sip.core.dispatchers.InitialRequestDispatcher.dispatchInsideContainer(InitialRequestDispatcher.java:451) [sip-servlets-impl-3.1.633.jar:3.1.633]
at org.mobicents.servlet.sip.core.dispatchers.InitialRequestDispatcher.dispatchMessage(InitialRequestDispatcher.java:306) [sip-servlets-impl-3.1.633.jar:3.1.633]
at org.mobicents.servlet.sip.core.SipApplicationDispatcherImpl.processRequest(SipApplicationDispatcherImpl.java:841) [sip-servlets-impl-3.1.633.jar:3.1.633]
at gov.nist.javax.sip.EventScanner.deliverEvent(EventScanner.java:230) [jain-sip-ri-1.2.242.jar:1.2.242]
at gov.nist.javax.sip.SipProviderImpl.handleEvent(SipProviderImpl.java:185) [jain-sip-ri-1.2.242.jar:1.2.242]
at gov.nist.javax.sip.DialogFilter.processRequest(DialogFilter.java:1324) [jain-sip-ri-1.2.242.jar:1.2.242]
at gov.nist.javax.sip.stack.SIPServerTransactionImpl.processRequest(SIPServerTransactionImpl.java:807) [jain-sip-ri-1.2.242.jar:1.2.242]
at gov.nist.javax.sip.stack.UDPMessageChannel.processMessage(UDPMessageChannel.java:560) [jain-sip-ri-1.2.242.jar:1.2.242]
at gov.nist.javax.sip.stack.UDPMessageChannel.processIncomingDataPacket(UDPMessageChannel.java:512) [jain-sip-ri-1.2.242.jar:1.2.242]
at gov.nist.javax.sip.stack.UDPMessageChannel.run(UDPMessageChannel.java:317) [jain-sip-ri-1.2.242.jar:1.2.242]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.7.0_95]
Caused by: java.net.ConnectException: Connection refused
at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method) [rt.jar:1.7.0_95]
at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:744) [rt.jar:1.7.0_95]
at sun.nio.ch.SocketAdaptor.connect(SocketAdaptor.java:117) [rt.jar:1.7.0_95]
at gov.nist.javax.sip.stack.NioTcpMessageProcessor.initiateConnection(NioTcpMessageProcessor.java:96) [jain-sip-ri-1.2.242.jar:1.2.242]
at gov.nist.javax.sip.stack.NioTcpMessageProcessor.blockingConnect(NioTcpMessageProcessor.java:109) [jain-sip-ri-1.2.242.jar:1.2.242]
at gov.nist.javax.sip.stack.NIOHandler.createOrReuseSocket(NIOHandler.java:408) [jain-sip-ri-1.2.242.jar:1.2.242]
at gov.nist.javax.sip.stack.NioTcpMessageChannel.<init>(NioTcpMessageChannel.java:192) [jain-sip-ri-1.2.242.jar:1.2.242]
at gov.nist.javax.sip.stack.NioTcpMessageProcessor.createMessageChannel(NioTcpMessageProcessor.java:394) [jain-sip-ri-1.2.242.jar:1.2.242]
at gov.nist.javax.sip.stack.SIPTransactionStack.createMessageChannel(SIPTransactionStack.java:1716) [jain-sip-ri-1.2.242.jar:1.2.242]
at gov.nist.javax.sip.SipProviderImpl.createClientTransaction(SipProviderImpl.java:389) [jain-sip-ri-1.2.242.jar:1.2.242]
at gov.nist.javax.sip.SipProviderImpl.getNewClientTransaction(SipProviderImpl.java:455) [jain-sip-ri-1.2.242.jar:1.2.242]
at org.mobicents.servlet.sip.message.SipServletRequestImpl.send(SipServletRequestImpl.java:1213) [sip-servlets-impl-3.1.633.jar:3.1.633]
at org.mobicents.servlet.sip.message.SipServletRequestImpl.send(SipServletRequestImpl.java:1009) [sip-servlets-impl-3.1.633.jar:3.1.633]
at com.mycompany.app.FunctionalAddressingServlet.doInvite(FunctionalAddressingServlet.java:100)
at javax.servlet.sip.SipServlet.doRequest(SipServlet.java:231) [sip-servlets-spec-3.1.633.jar:3.1.633]
at javax.servlet.sip.SipServlet.service(SipServlet.java:328) [sip-servlets-spec-3.1.633.jar:3.1.633]
at org.mobicents.servlet.sip.core.dispatchers.MessageDispatcher.callServlet(MessageDispatcher.java:369) [sip-servlets-impl-3.1.633.jar:3.1.633]
at org.mobicents.servlet.sip.core.dispatchers.InitialRequestDispatcher$InitialDispatchTask.dispatch(InitialRequestDispatcher.java:746) [sip-servlets-impl-3.1.633.jar:3.1.633]
... 12 more
这是doInvite()
protected void doInvite(SipServletRequest request) throws ServletException, IOException {
B2buaHelper b2buaHelper = request.getB2buaHelper();
SipSession session = request.getSession();
Map<String, List<String>> headerMap = new HashMap<String, List<String>>();
SipFactory sipFactory = (SipFactory) getServletContext().getAttribute(SIP_FACTORY);
SipURI destination = (SipURI) sipFactory.createURI("sip:bob@kam.ims");
SipServletRequest forkedRequest = b2buaHelper.createRequest(request, true, headerMap);
forkedRequest.setRequestURI(destination);
forkedRequest.getSession().setAttribute("originalRequest", request);
forkedRequest.send();
}
难道是应用程序无法解析域名?如果是这样,在JBOSS中是否应该进行一些特定的配置?
任何提示将不胜感激,在此先感谢!
编辑:
将 gov.nist 的日志记录级别增加到 INFO 后,可以看到:
18:52:07,921 INFO [gov.nist.javax.sip.stack.NIOHandler] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) Problem connecting /10.0.0.102 5061 /10.0.0.102
18:52:07,922 INFO [gov.nist.javax.sip.stack.NIOHandler] (Mobicents-SIP-Servlets-UDPMessageChannelThread-4) Problem OpeningConn: inAddr 10.0.0.102 port = 5061 retry false
我现在不明白 5061 是从哪里获取的。请求的来源是:
18:52:07,946 INFO [gov.nist.javax.sip.stack.UDPMessageChannel] (Mobicents-SIP-Servlets-UDPMessageChannelThread-5) Setting SIPMessage peerPacketSource to: /10.0.0.102:5060
并且响应应该被发送回同一个端口。
INVITE 中的联系头包含 udp 作为传输协议:
Contact: <sip:alice@10.0.0.100:54479;transport=udp>;+g.oma.sip-im