JAIN-SIP RINGING响应永远不会被发送

时间:2010-12-21 23:00:34

标签: java sip jain-sip

我正在创建一个实现SipListener接口的类来接收来自JAIN-SIP堆栈的事件(对于Android设备)。为了测试它,我将2个设备连接到OpenSIP,并尝试呼叫另一个。我使用第三方客户端没问题。

除了一个奇怪的问题外,一切似乎都与我的基本实现一致。当我在processRequest中收到INVITE请求时,我创建了一个RINGING响应,然后是OK响应。问题是(根据tcpdump)RINGING响应永远不会到达服务器。收到INVITE数据包后,设备会发送一个TRYING数据包(我不会在我的代码中执行此操作,因此它必须是JAIN-SIP的一部分)并使用OK数据包进行跟踪。我遵循了各种各样的例子,他们似乎都在这些方面提出了一些建议:

//This function gets called from processRequest
//Some initialization code removed to keep this short
private void processInvite(RequestEvent requestEvent)
{
        ServerTransaction serverTransaction = requestEvent.getServerTransaction();
        SipProvider sipProvider = (SipProvider) requestEvent.getSource();
            Request request = requestEvent.getRequest();

        //Create RINGING response
        Response response = m_messageFactory.createResponse(Response.RINGING,
        request);

        //Add a contact header
        Address contactAddress = m_addressFactory
        .createAddress(m_username + " <sip:" + getLocalIpAddress() + ":" + m_sipPort + ">");

        ContactHeader contactHeader = m_headerFactory.createContactHeader(contactAddress);

        response.addHeader(contactHeader);

        if (serverTransaction == null)
            {
                serverTransaction = sipProvider.getNewServerTransaction(request);
            }

        //Send RINGING response
        //This never makes it to the server
        serverTransaction.sendResponse(response);

        //Create OK response
        Response okResponse = m_messageFactory.createResponse(Response.OK, request);
        ToHeader toHeader = (ToHeader) okResponse.getHeader(ToHeader.NAME);
        toHeader.setTag("4321");
        okResponse.addHeader(contactHeader);

        //Send OK Response
        //This makes it to the server
        serverTransaction.sendResponse(okResponse);
}

作为参考,INVITE标题如下所示:

INVITE sip:4321@64.x.x.x:5060 SIP/2.0  
Call-ID: 25e87b79f720728c6676d492e10c5984@10.x.x.10  
CSeq: 20 INVITE  
From: "Caller" <sip:1234@64.x.x.x:5060>;tag=12345  
To: "Callee" <sip:4321@64.x.x.x:5060>  
Via: SIP/2.0/UDP 10.x.x.10:5060;branch=z9hG4bKe45cd7919b5177a806ec1a9238b841f9393739  
Max-Forwards: 70  
Contact: "4321" <sip:1234@10.x.x.10:5060>  
Content-Length: 0  

64.x.x.x是OpenSIPs IP,10.x.x.10是UAC的IP。

我是否错过了标题或以其他方式错误地设置了RINGING数据包?非常感谢任何帮助!

1 个答案:

答案 0 :(得分:0)

我认为它不是正在发送尝试消息的被叫方,而是正在发送消息的opensips,它应该在尝试联系被叫方时发送。我很确定没有发送振铃消息,因为你没有为它设置toheader。