1

I want automatically answer all sip calls. When I respond with trying or ringing, the transaction is in a proceeding state, but when I send the OK response, the transaction is in a terminated state. This is my code:

public void processRequest(RequestEvent requestReceivedEvent)
{
    Address contactAddress = myAddressFactory.createAddress("sip:" + myIP + ":" + myPort);
    myContactHeader = myHeaderFactory.createContactHeader(contactAddress);
    Request req = requestReceivedEvent.getRequest();
    myGUI.display("<<< " + req.toString());
    String method = req.getMethod(); //bad request type.                 
    FromHeader from = (FromHeader) req.getHeader("From");
    Response response = null;
    try
    { //Reply with OK                 
        response = myMessageFactory.createResponse(200, req);
        ToHeader toHeader = (ToHeader) response.getHeader(ToHeader.NAME);
        toHeader.setTag("888"); //Identifier, specific to your application                 
        ServerTransaction st = mySipProvider.getNewServerTransaction(req);
        response.addHeader(myContactHeader);
        st.sendResponse(response);
        System.out.println("Ok response: " + st.getState());

    }
    catch (Exception e)
    {
        e.printStackTrace();
    }
}

Thanks in advance.

DwB
  • 37,124
  • 11
  • 56
  • 82
Anar Orujov
  • 591
  • 5
  • 18

1 Answers1

4

INVITE server transactions to go terminated state after 200 OK. It's normal. Your call is answered and you shouldn't worry about it.

(see diagram of state machine from RFC)

                           |INVITE
                           |pass INV to TU
        INVITE             V send 100 if TU won't in 200ms
        send response+-----------+
            +--------|           |--------+101-199 from TU
            |        | Proceeding|        |send response
            +------->|           |<-------+
                     |           |          Transport Err.
                     |           |          Inform TU
                     |           |--------------->+
                     +-----------+                |
        300-699 from TU |     |2xx from TU        |
        send response   |     |send response      |
                        |     +------------------>+
                        |                         |
        INVITE          V          Timer G fires  |
        send response+-----------+ send response  |
            +--------|           |--------+       |
            |        | Completed |        |       |
            +------->|           |<-------+       |
                     +-----------+                |
                        |     |                   |
                    ACK |     |                   |
                    -   |     +------------------>+
                        |        Timer H fires    |
                        V        or Transport Err.|
                     +-----------+  Inform TU     |
                     |           |                |
                     | Confirmed |                |
                     |           |                |
                     +-----------+                |
                           |                      |
                           |Timer I fires         |
                           |-                     |
                           |                      |
                           V                      |
                     +-----------+                |
                     |           |                |
                     | Terminated|<---------------+
                     |           |
                     +-----------+

          Figure 7: INVITE server transaction
Vladimir Ralev
  • 1,371
  • 9
  • 18
  • but I didn't get ACK and BYE messages – Anar Orujov Feb 10 '15 at 19:07
  • 2
    ACK and BYE must be new transactions within the same dialog. With some exceptions that you shouldn't care about right now. – Vladimir Ralev Feb 10 '15 at 19:20
  • I need to answer all calls automatically and get notificiation about end of call. I have sip calls with sip trunk from CUCM 9. Do I need create client sip proxy and sip phone in my side or I can do it only with sip listener? – Anar Orujov Feb 10 '15 at 19:30
  • I used sip proxy only for registering sip phone and sip calls go to sip phone without sip proxy, I could answer and got rtp stream, but I didn't got ACK and BYE messages. Sorry for my bad English :) – Anar Orujov Feb 10 '15 at 19:35
  • 1
    Check this example. It should have everything you need, you just need to trace it and customize it https://svn.java.net/svn/jsip~svn/trunk/src/examples/simplecallsetup/Shootme.java – Vladimir Ralev Feb 10 '15 at 20:39
  • Thanks a lot, everything was succesfull! – Anar Orujov Feb 11 '15 at 06:08