Search code examples
javaandroidsippjsip

"INVITE SESSION ALREADY TERMINATED ERROR" while trying to handle incoming call via pjsip(PJSUA2)


I have successfully made outgoing call via PJSIP. Now facing a problem while try to handle incoming call.

Thread isanycall=new Thread(new Runnable() {
        @Override
        public void run() {
            while(true)
            {
                if(Global.isanycall==1)
                {

                    sipOperationIncoming(username, pwd, ip, number.getText().toString());

                    Global.isanycall=0;
                }
            }
        }
    });
    isanycall.start();

This code is checking if there is any incoming call.

System.out.println("Incoming call handler");

    //sip operation started
    registration=SipRegistration.getSipRegistration(uname,pwd,ip);
    registration.answerCall(da);
    //sip operation ended

This code block is just responsible to call a function answerCall which is as follow

public void answerCall(DialerActivity activity){

    call=new MyCall(myacc,1,this.ep,activity);

    CallOpParam prm = new CallOpParam();

    prm.setStatusCode(pjsip_status_code.PJSIP_SC_RINGING);

    try {
        call.answer(prm);

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

Now the exception I am getting is

java.lang.Exception: Title:       pjsua_call_answer2(id, param.p_opt, prm.statusCode, param.p_reason, param.p_msg_data)
10-27 12:11:19.839 10090-10384/com.skyteloutsourcing.callnxt W/System.err: Code:        171140
10-27 12:11:19.839 10090-10384/com.skyteloutsourcing.callnxt W/System.err: Description: INVITE session already terminated (PJSIP_ESESSIONTERMINATED)

What can be the reason?


Solution

  • Solved it, I was responding with a different call id rather than which was the call id of incoming call. :)