1

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

除了一个奇怪的问题外,我的基本实现似乎一切都很好。当我在 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.xxx 是 OpenSIPs IP,10.xx10 是 UAC 的 IP。

我是否缺少标头或以其他方式错误地设置了 RINGING 数据包?任何帮助是极大的赞赏!

4

1 回答 1

0

i think its not the callee that is sending the trying message but the opensips which is sending the message, which it is supposed to send while it is trying to contact the callee. and i am pretty sure the ringing message is not being sent because you havent set the toheader for it.

于 2011-01-07T07:01:36.063 回答