Pergunta

I am creating a class that implements the SipListener interface to receive events from the JAIN-SIP stack (for an Android device). To test it, I connect 2 devices to an OpenSIPs and have one try to call the other. I have no problem using 3rd party clients.

Everything seems to be working well with my basic implementation, except for one strange problem. When I receive the INVITE request in processRequest, I create a RINGING response, followed by an OK response. The problem is that (according to tcpdump) the RINGING response never gets to the server. After the INVITE packet is received, the device sends out a TRYING packet (I don't do it in my code, so it must be part of JAIN-SIP) and follows it up with an OK packet. I followed various examples and they all seem to suggest something along these lines:

//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);
}

For reference, the INVITE headers look like this:

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  

with 64.x.x.x being the OpenSIPs IP and 10.x.x.10 being the UAC's IP.

Am I missing a header or otherwise setting up the RINGING packet incorrectly? Any help is greatly appreciated!

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top