Java 实现取消请求

Java 实现取消请求,java,sip,jain-sip,cancel-button,Java,Sip,Jain Sip,Cancel Button,我正在执行取消正在进行的呼叫请求。我尝试在会话建立后发送请求。cancel函数在我第一次实现它时起作用,但现在它表示事务存在。我怎么修理它 else if(currentREsponse.equals("Session Progress")){ System.out.println("------------------- Status Code: "+ statusCode+ "--------------------------"); Syst

我正在执行取消正在进行的呼叫请求。我尝试在会话建立后发送请求。cancel函数在我第一次实现它时起作用,但现在它表示事务存在。我怎么修理它

else if(currentREsponse.equals("Session Progress")){
            System.out.println("------------------- Status Code: "+ statusCode+ "--------------------------");
            System.out.println(responseEvent.getResponse());
            try {

                Request cancelRequest;
                cancelRequest = inviteTid.createCancel();
                ClientTransaction canceltid = sipProvider.getNewClientTransaction(cancelRequest);
                canceltid.sendRequest();
                System.out.println("Cancel Requst:" + cancelRequest);
            } catch (SipException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } 
        }
答复:

-----------StatusCode:100----------------------------
-----------currentREsponse:Trying----------------------------
------------------- Status Code: 100--------------------------
SIP/2.0 100 Trying
Via: SIP/2.0/UDP localIP:52216;branch=z9hG4bK-353435-03dc537ef691bb00e1e5512b034ea431;received=localIP;rport=52216
From: <sip:username@sipIP>;tag=-2016245219
To: <sip:86940160@sipIP>
Call-ID: fab08b0be8c74b236c9eced419dec3ae@localIP
CSeq: 5 INVITE
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
Contact: <sip:86940160@sipIP:5060>
Content-Length: 0


------------------- Phone is RINGING hangup --------------------------


Request OPTIONSreceived at stackwith server transaction idnull
-----------StatusCode:183----------------------------
-----------currentREsponse:Session Progress----------------------------
------------------- Status Code: 183--------------------------
SIP/2.0 183 Session Progress
Via: SIP/2.0/UDP localIP:52216;branch=z9hG4bK-353435-03dc537ef691bb00e1e5512b034ea431;received=localIP;rport=52216
From: <sip:username@sipIP>;tag=-2016245219
To: <sip:86940160@sipIP>;tag=as06d748b5
Call-ID: fab08b0be8c74b236c9eced419dec3ae@localIP
CSeq: 5 INVITE
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
Contact: <sip:86940160@sipIP:5060>
Content-Type: application/sdp
Content-Length: 254

v=0
o=root 16865513 16865513 IN IP4 sipIP
s=Asterisk PBX 10.5.1
c=IN IP4 sipIP
t=0 0
m=audio 16188 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
a=sendrecv

Cancel Requst:CANCEL sip:86940160@sipIP SIP/2.0
Call-ID: fab08b0be8c74b236c9eced419dec3ae@localIP
To: <sip:86940160@sipIP>
CSeq: 5 CANCEL
From: <sip:username@sipIP>;tag=-2016245219
Via: SIP/2.0/UDP localIP:52216;rport;branch=z9hG4bK-353435-32ce00c8a1c2efc96caa44a14bf3b910
Max-Forwards: 70
Content-Length: 0




Request OPTIONSreceived at stackwith server transaction idnull
-----------StatusCode:401----------------------------
-----------currentREsponse:Unauthorized----------------------------
---------------UNAUTHORIZED--------SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP localIP:52216;branch=z9hG4bK-353435-32ce00c8a1c2efc96caa44a14bf3b910;received=localIP;rport=52216
From: <sip:username@sipIP>;tag=-2016245219
To: <sip:86940160@sipIP>;tag=as647be936
Call-ID: fab08b0be8c74b236c9eced419dec3ae@localIP
CSeq: 5 INVITE
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
WWW-Authenticate: Digest algorithm=MD5,realm="xyz.com",nonce="69e1f4c2"
Content-Length: 0


-----------StatusCode:481----------------------------
-----------currentREsponse:Call/Transaction Does Not Exist----------------------------
-------------------Status Code: 481 ----------------------
SIP/2.0 481 Call/Transaction Does Not Exist
Via: SIP/2.0/UDP 10.99.136.131:52216;branch=z9hG4bK-353435-32ce00c8a1c2efc96caa44a14bf3b910;received=10.99.136.131;rport=52216
From: <sip:username@sipIP>;tag=-2016245219
To: <sip:86940160@sipIP>;tag=as647be936
Call-ID: fab08b0be8c74b236c9eced419dec3ae@10.99.136.131
CSeq: 5 CANCEL
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
Content-Length: 0


Request OPTIONSreceived at stackwith server transaction idnull
private void processInviteResponse(ResponseEvent responseReceivedEvent) throws SipException, InvalidArgumentException {
        int statusCode = responseReceivedEvent.getResponse().getStatusCode();
        String currentResponse = responseReceivedEvent.getResponse().getReasonPhrase();
        Response response = responseReceivedEvent.getResponse();
        ClientTransaction tid = responseReceivedEvent.getClientTransaction();
        CSeqHeader cseqtemp = (CSeqHeader) response.getHeader(CSeqHeader.NAME);
        if(statusCode> 400 && statusCode <410){
            if((statusCode ==401 && cseqtemp.getMethod().equals(Request.INVITE))
                    || response.getStatusCode() == Response.PROXY_AUTHENTICATION_REQUIRED){
                System.out.println(responseReceivedEvent.getResponse().toString());
//              if(functions.cseq<4){

                    System.out.println("------------------Invite 401--------------------\n");

                    AuthenticationHelper authenticationHelper = 
                            ((SipStackExt) functions.sipStack).getAuthenticationHelper(new AccountManagerImpl(), functions.headerFactory);
                    try {
                        functions.inviteTid = authenticationHelper.handleChallenge(response, functions.inviteTid, functions.sipProvider, 5);
                        functions.inviteTid.sendRequest();
                        System.out.println("/n" + functions.inviteTid.getRequest());
                    } catch (NullPointerException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (SipException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
//                  functions.call(responseReceivedEvent.getResponse());
//              }
            }
        }else if(statusCode == 200){
            try {
                System.out.println(responseReceivedEvent.getResponse().toString());

                response = (Response) responseReceivedEvent.getResponse();
                tid = responseReceivedEvent.getClientTransaction();
                CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);     
                Dialog dialog = responseReceivedEvent.getDialog();


                if (tid == null) {
                    // RFC3261: MUST respond to every 2xx
                    if (ackRequest!=null && dialog!=null) {
                        System.out.println("re-sending ACK");
                        dialog.sendAck(ackRequest);
                    }
                    return;
                }

                if (response.getStatusCode() == Response.OK) {
                    System.out.println("Dialog after 200 OK  " + dialog);
                    System.out.println("Dialog State after 200 OK  " + dialog.getState());
                    ackRequest = dialog.createAck(cseq.getSeqNumber() );
                    System.out.println("Sending ACK");
                    dialog.sendAck(ackRequest);
                }



                }
             catch (InvalidArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SipException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }else if(responseReceivedEvent.getResponse().getReasonPhrase().equals("Trying")){
            System.out.println("------------------- Status Code: "+ statusCode+ "--------------------------");
            System.out.println(responseReceivedEvent.getResponse());


        }else if(responseReceivedEvent.getResponse().getReasonPhrase().equals("Ringing")){
            System.out.println("------------------- Status Code: "+ statusCode+ "--------------------------");
            System.out.println(responseReceivedEvent.getResponse());
            System.out.println("------------------- Phone is RINGING --------------------------");


        }else if(responseReceivedEvent.getResponse().getReasonPhrase().equals("Session Progress")){
            System.out.println("------------------- Status Code: "+ statusCode+ "--------------------------");
            System.out.println(responseReceivedEvent.getResponse());
//          functions.cancel(response);

            Request cancelRequest= responseReceivedEvent.getClientTransaction().createCancel();

            functions.sipProvider.sendRequest(cancelRequest);
            System.out.println(cancelRequest.toString());
        }else {
            System.out.println("------------------- Status Code: "+ statusCode+ "--------------------------");
            System.out.println(responseReceivedEvent.getResponse());
        }


    }
REGISTER sip:sipIP SIP/2.0
Call-ID: cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq: 1 REGISTER
From: <sip:username@sipIP>;tag=-1436906198
To: <sip:username@sipIP>
Via: SIP/2.0/UDP localIP:52216;rport;branch=z9hG4bK-3230-3d42d8c86f8aa3d6d0194a4846511464
Max-Forwards: 70
Contact: <sip:username@localIP:52216;transport=UDP>
Content-Length: 0


log4j:WARN No appenders could be found for logger (test).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
................cseqCSeq: 1 REGISTER

SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP localIP:52216;branch=z9hG4bK-3230-3d42d8c86f8aa3d6d0194a4846511464;received=localIP;rport=52216
From: <sip:username@sipIP>;tag=-1436906198
To: <sip:username@sipIP>;tag=as24ab6bcf
Call-ID: cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq: 1 REGISTER
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
WWW-Authenticate: Digest algorithm=MD5,realm="xyz.com",nonce="6ac7ff34"
Content-Length: 0


REGISTER sip:sipIP SIP/2.0
Call-ID: cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq: 2 REGISTER
From: <sip:username@sipIP>;tag=-1436906198
To: <sip:username@sipIP>
Via: SIP/2.0/UDP localIP:52216;rport;branch=z9hG4bK-3230-a94c094a3aacfc40d0455de777b0ae26
Max-Forwards: 70
Contact: <sip:username@localIP:52216;transport=UDP>
Authorization: Digest username="username",realm="xyz.com",nonce="6ac7ff34",uri="sip:sipIP",algorithm=MD5,response="53231e4a2cd26604d8d2bc867b0e43e9"
Content-Length: 0


................cseqCSeq: 2 REGISTER

---------------------------Registered: 200--------------------

SIP/2.0 200 OK
Via: SIP/2.0/UDP localIP:52216;branch=z9hG4bK-3230-a94c094a3aacfc40d0455de777b0ae26;received=localIP;rport=52216
From: <sip:username@sipIP>;tag=-1436906198
To: <sip:username@sipIP>;tag=as24ab6bcf
Call-ID: cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq: 2 REGISTER
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
Expires: 240
Contact: <sip:username@localIP:52216;transport=UDP>;expires=240
Date: Thu, 30 Apr 2015 14:46:46 GMT
Content-Length: 0


Dialog: createdgov.nist.javax.sip.stack.SIPDialog@79f65165
INVITE sip:86940160@sipIP SIP/2.0
Call-ID: cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq: 3 INVITE
From: <sip:username@sipIP>;tag=-1436906198
To: <sip:86940160@sipIP>
Via: SIP/2.0/UDP localIP:52216;rport;branch=z9hG4bK-3230-c5512f65af9890c0798f1e5757ef1c57
Max-Forwards: 70
Content-Type: application/sdp
Contact: <sip:username@localIP:52216;transport=UDP>
Authorization: Digest username="username",realm="xyz.com",nonce="6ac7ff34",uri="sip:sipIP",algorithm=MD5,response="53231e4a2cd26604d8d2bc867b0e43e9"
Content-Length: 211

v=0
o=user1 795808818 480847547 IN IP4 localIP
s=-
c=IN IP4 localIP
t=0 0
m=audio 8000 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=sendrecv


Request OPTIONSreceived at stackwith server transaction idnull


Request OPTIONSreceived at stackwith server transaction idnull
................cseqCSeq: 3 INVITE

.....countInviteResponse: 1 ......
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP localIP:52216;branch=z9hG4bK-3230-c5512f65af9890c0798f1e5757ef1c57;received=localIP;rport=52216
From: <sip:username@sipIP>;tag=-1436906198
To: <sip:86940160@sipIP>;tag=as43ee81b7
Call-ID: cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq: 3 INVITE
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
WWW-Authenticate: Digest algorithm=MD5,realm="xyz.com",nonce="6ad3bcf0"
Content-Length: 0
ProcessInvite响应:

private void processInviteResponse(ResponseEvent responseReceivedEvent) throws SipException, InvalidArgumentException {
        int statusCode = responseReceivedEvent.getResponse().getStatusCode();
        String currentResponse = responseReceivedEvent.getResponse().getReasonPhrase();
        Response response = responseReceivedEvent.getResponse();
        ClientTransaction tid = responseReceivedEvent.getClientTransaction();
        CSeqHeader cseqtemp = (CSeqHeader) response.getHeader(CSeqHeader.NAME);
        if(statusCode> 400 && statusCode <410){
            if((statusCode ==401 && cseqtemp.getMethod().equals(Request.INVITE))
                    || response.getStatusCode() == Response.PROXY_AUTHENTICATION_REQUIRED){
                System.out.println(responseReceivedEvent.getResponse().toString());
//              if(functions.cseq<4){

                    System.out.println("------------------Invite 401--------------------\n");

                    AuthenticationHelper authenticationHelper = 
                            ((SipStackExt) functions.sipStack).getAuthenticationHelper(new AccountManagerImpl(), functions.headerFactory);
                    try {
                        functions.inviteTid = authenticationHelper.handleChallenge(response, functions.inviteTid, functions.sipProvider, 5);
                        functions.inviteTid.sendRequest();
                        System.out.println("/n" + functions.inviteTid.getRequest());
                    } catch (NullPointerException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (SipException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
//                  functions.call(responseReceivedEvent.getResponse());
//              }
            }
        }else if(statusCode == 200){
            try {
                System.out.println(responseReceivedEvent.getResponse().toString());

                response = (Response) responseReceivedEvent.getResponse();
                tid = responseReceivedEvent.getClientTransaction();
                CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);     
                Dialog dialog = responseReceivedEvent.getDialog();


                if (tid == null) {
                    // RFC3261: MUST respond to every 2xx
                    if (ackRequest!=null && dialog!=null) {
                        System.out.println("re-sending ACK");
                        dialog.sendAck(ackRequest);
                    }
                    return;
                }

                if (response.getStatusCode() == Response.OK) {
                    System.out.println("Dialog after 200 OK  " + dialog);
                    System.out.println("Dialog State after 200 OK  " + dialog.getState());
                    ackRequest = dialog.createAck(cseq.getSeqNumber() );
                    System.out.println("Sending ACK");
                    dialog.sendAck(ackRequest);
                }



                }
             catch (InvalidArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SipException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }else if(responseReceivedEvent.getResponse().getReasonPhrase().equals("Trying")){
            System.out.println("------------------- Status Code: "+ statusCode+ "--------------------------");
            System.out.println(responseReceivedEvent.getResponse());


        }else if(responseReceivedEvent.getResponse().getReasonPhrase().equals("Ringing")){
            System.out.println("------------------- Status Code: "+ statusCode+ "--------------------------");
            System.out.println(responseReceivedEvent.getResponse());
            System.out.println("------------------- Phone is RINGING --------------------------");


        }else if(responseReceivedEvent.getResponse().getReasonPhrase().equals("Session Progress")){
            System.out.println("------------------- Status Code: "+ statusCode+ "--------------------------");
            System.out.println(responseReceivedEvent.getResponse());
//          functions.cancel(response);

            Request cancelRequest= responseReceivedEvent.getClientTransaction().createCancel();

            functions.sipProvider.sendRequest(cancelRequest);
            System.out.println(cancelRequest.toString());
        }else {
            System.out.println("------------------- Status Code: "+ statusCode+ "--------------------------");
            System.out.println(responseReceivedEvent.getResponse());
        }


    }
答复:

-----------StatusCode:100----------------------------
-----------currentREsponse:Trying----------------------------
------------------- Status Code: 100--------------------------
SIP/2.0 100 Trying
Via: SIP/2.0/UDP localIP:52216;branch=z9hG4bK-353435-03dc537ef691bb00e1e5512b034ea431;received=localIP;rport=52216
From: <sip:username@sipIP>;tag=-2016245219
To: <sip:86940160@sipIP>
Call-ID: fab08b0be8c74b236c9eced419dec3ae@localIP
CSeq: 5 INVITE
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
Contact: <sip:86940160@sipIP:5060>
Content-Length: 0


------------------- Phone is RINGING hangup --------------------------


Request OPTIONSreceived at stackwith server transaction idnull
-----------StatusCode:183----------------------------
-----------currentREsponse:Session Progress----------------------------
------------------- Status Code: 183--------------------------
SIP/2.0 183 Session Progress
Via: SIP/2.0/UDP localIP:52216;branch=z9hG4bK-353435-03dc537ef691bb00e1e5512b034ea431;received=localIP;rport=52216
From: <sip:username@sipIP>;tag=-2016245219
To: <sip:86940160@sipIP>;tag=as06d748b5
Call-ID: fab08b0be8c74b236c9eced419dec3ae@localIP
CSeq: 5 INVITE
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
Contact: <sip:86940160@sipIP:5060>
Content-Type: application/sdp
Content-Length: 254

v=0
o=root 16865513 16865513 IN IP4 sipIP
s=Asterisk PBX 10.5.1
c=IN IP4 sipIP
t=0 0
m=audio 16188 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
a=sendrecv

Cancel Requst:CANCEL sip:86940160@sipIP SIP/2.0
Call-ID: fab08b0be8c74b236c9eced419dec3ae@localIP
To: <sip:86940160@sipIP>
CSeq: 5 CANCEL
From: <sip:username@sipIP>;tag=-2016245219
Via: SIP/2.0/UDP localIP:52216;rport;branch=z9hG4bK-353435-32ce00c8a1c2efc96caa44a14bf3b910
Max-Forwards: 70
Content-Length: 0




Request OPTIONSreceived at stackwith server transaction idnull
-----------StatusCode:401----------------------------
-----------currentREsponse:Unauthorized----------------------------
---------------UNAUTHORIZED--------SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP localIP:52216;branch=z9hG4bK-353435-32ce00c8a1c2efc96caa44a14bf3b910;received=localIP;rport=52216
From: <sip:username@sipIP>;tag=-2016245219
To: <sip:86940160@sipIP>;tag=as647be936
Call-ID: fab08b0be8c74b236c9eced419dec3ae@localIP
CSeq: 5 INVITE
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
WWW-Authenticate: Digest algorithm=MD5,realm="xyz.com",nonce="69e1f4c2"
Content-Length: 0


-----------StatusCode:481----------------------------
-----------currentREsponse:Call/Transaction Does Not Exist----------------------------
-------------------Status Code: 481 ----------------------
SIP/2.0 481 Call/Transaction Does Not Exist
Via: SIP/2.0/UDP 10.99.136.131:52216;branch=z9hG4bK-353435-32ce00c8a1c2efc96caa44a14bf3b910;received=10.99.136.131;rport=52216
From: <sip:username@sipIP>;tag=-2016245219
To: <sip:86940160@sipIP>;tag=as647be936
Call-ID: fab08b0be8c74b236c9eced419dec3ae@10.99.136.131
CSeq: 5 CANCEL
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
Content-Length: 0


Request OPTIONSreceived at stackwith server transaction idnull
private void processInviteResponse(ResponseEvent responseReceivedEvent) throws SipException, InvalidArgumentException {
        int statusCode = responseReceivedEvent.getResponse().getStatusCode();
        String currentResponse = responseReceivedEvent.getResponse().getReasonPhrase();
        Response response = responseReceivedEvent.getResponse();
        ClientTransaction tid = responseReceivedEvent.getClientTransaction();
        CSeqHeader cseqtemp = (CSeqHeader) response.getHeader(CSeqHeader.NAME);
        if(statusCode> 400 && statusCode <410){
            if((statusCode ==401 && cseqtemp.getMethod().equals(Request.INVITE))
                    || response.getStatusCode() == Response.PROXY_AUTHENTICATION_REQUIRED){
                System.out.println(responseReceivedEvent.getResponse().toString());
//              if(functions.cseq<4){

                    System.out.println("------------------Invite 401--------------------\n");

                    AuthenticationHelper authenticationHelper = 
                            ((SipStackExt) functions.sipStack).getAuthenticationHelper(new AccountManagerImpl(), functions.headerFactory);
                    try {
                        functions.inviteTid = authenticationHelper.handleChallenge(response, functions.inviteTid, functions.sipProvider, 5);
                        functions.inviteTid.sendRequest();
                        System.out.println("/n" + functions.inviteTid.getRequest());
                    } catch (NullPointerException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    } catch (SipException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
//                  functions.call(responseReceivedEvent.getResponse());
//              }
            }
        }else if(statusCode == 200){
            try {
                System.out.println(responseReceivedEvent.getResponse().toString());

                response = (Response) responseReceivedEvent.getResponse();
                tid = responseReceivedEvent.getClientTransaction();
                CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);     
                Dialog dialog = responseReceivedEvent.getDialog();


                if (tid == null) {
                    // RFC3261: MUST respond to every 2xx
                    if (ackRequest!=null && dialog!=null) {
                        System.out.println("re-sending ACK");
                        dialog.sendAck(ackRequest);
                    }
                    return;
                }

                if (response.getStatusCode() == Response.OK) {
                    System.out.println("Dialog after 200 OK  " + dialog);
                    System.out.println("Dialog State after 200 OK  " + dialog.getState());
                    ackRequest = dialog.createAck(cseq.getSeqNumber() );
                    System.out.println("Sending ACK");
                    dialog.sendAck(ackRequest);
                }



                }
             catch (InvalidArgumentException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (SipException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }else if(responseReceivedEvent.getResponse().getReasonPhrase().equals("Trying")){
            System.out.println("------------------- Status Code: "+ statusCode+ "--------------------------");
            System.out.println(responseReceivedEvent.getResponse());


        }else if(responseReceivedEvent.getResponse().getReasonPhrase().equals("Ringing")){
            System.out.println("------------------- Status Code: "+ statusCode+ "--------------------------");
            System.out.println(responseReceivedEvent.getResponse());
            System.out.println("------------------- Phone is RINGING --------------------------");


        }else if(responseReceivedEvent.getResponse().getReasonPhrase().equals("Session Progress")){
            System.out.println("------------------- Status Code: "+ statusCode+ "--------------------------");
            System.out.println(responseReceivedEvent.getResponse());
//          functions.cancel(response);

            Request cancelRequest= responseReceivedEvent.getClientTransaction().createCancel();

            functions.sipProvider.sendRequest(cancelRequest);
            System.out.println(cancelRequest.toString());
        }else {
            System.out.println("------------------- Status Code: "+ statusCode+ "--------------------------");
            System.out.println(responseReceivedEvent.getResponse());
        }


    }
REGISTER sip:sipIP SIP/2.0
Call-ID: cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq: 1 REGISTER
From: <sip:username@sipIP>;tag=-1436906198
To: <sip:username@sipIP>
Via: SIP/2.0/UDP localIP:52216;rport;branch=z9hG4bK-3230-3d42d8c86f8aa3d6d0194a4846511464
Max-Forwards: 70
Contact: <sip:username@localIP:52216;transport=UDP>
Content-Length: 0


log4j:WARN No appenders could be found for logger (test).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
................cseqCSeq: 1 REGISTER

SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP localIP:52216;branch=z9hG4bK-3230-3d42d8c86f8aa3d6d0194a4846511464;received=localIP;rport=52216
From: <sip:username@sipIP>;tag=-1436906198
To: <sip:username@sipIP>;tag=as24ab6bcf
Call-ID: cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq: 1 REGISTER
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
WWW-Authenticate: Digest algorithm=MD5,realm="xyz.com",nonce="6ac7ff34"
Content-Length: 0


REGISTER sip:sipIP SIP/2.0
Call-ID: cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq: 2 REGISTER
From: <sip:username@sipIP>;tag=-1436906198
To: <sip:username@sipIP>
Via: SIP/2.0/UDP localIP:52216;rport;branch=z9hG4bK-3230-a94c094a3aacfc40d0455de777b0ae26
Max-Forwards: 70
Contact: <sip:username@localIP:52216;transport=UDP>
Authorization: Digest username="username",realm="xyz.com",nonce="6ac7ff34",uri="sip:sipIP",algorithm=MD5,response="53231e4a2cd26604d8d2bc867b0e43e9"
Content-Length: 0


................cseqCSeq: 2 REGISTER

---------------------------Registered: 200--------------------

SIP/2.0 200 OK
Via: SIP/2.0/UDP localIP:52216;branch=z9hG4bK-3230-a94c094a3aacfc40d0455de777b0ae26;received=localIP;rport=52216
From: <sip:username@sipIP>;tag=-1436906198
To: <sip:username@sipIP>;tag=as24ab6bcf
Call-ID: cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq: 2 REGISTER
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
Expires: 240
Contact: <sip:username@localIP:52216;transport=UDP>;expires=240
Date: Thu, 30 Apr 2015 14:46:46 GMT
Content-Length: 0


Dialog: createdgov.nist.javax.sip.stack.SIPDialog@79f65165
INVITE sip:86940160@sipIP SIP/2.0
Call-ID: cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq: 3 INVITE
From: <sip:username@sipIP>;tag=-1436906198
To: <sip:86940160@sipIP>
Via: SIP/2.0/UDP localIP:52216;rport;branch=z9hG4bK-3230-c5512f65af9890c0798f1e5757ef1c57
Max-Forwards: 70
Content-Type: application/sdp
Contact: <sip:username@localIP:52216;transport=UDP>
Authorization: Digest username="username",realm="xyz.com",nonce="6ac7ff34",uri="sip:sipIP",algorithm=MD5,response="53231e4a2cd26604d8d2bc867b0e43e9"
Content-Length: 211

v=0
o=user1 795808818 480847547 IN IP4 localIP
s=-
c=IN IP4 localIP
t=0 0
m=audio 8000 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=sendrecv


Request OPTIONSreceived at stackwith server transaction idnull


Request OPTIONSreceived at stackwith server transaction idnull
................cseqCSeq: 3 INVITE

.....countInviteResponse: 1 ......
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP localIP:52216;branch=z9hG4bK-3230-c5512f65af9890c0798f1e5757ef1c57;received=localIP;rport=52216
From: <sip:username@sipIP>;tag=-1436906198
To: <sip:86940160@sipIP>;tag=as43ee81b7
Call-ID: cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq: 3 INVITE
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
WWW-Authenticate: Digest algorithm=MD5,realm="xyz.com",nonce="6ad3bcf0"
Content-Length: 0
注册sip:sipIP sip/2.0
呼叫ID:cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq:1寄存器
发件人:;标签=-1436906198
致:
Via:SIP/2.0/UDP localIP:52216;rport;分支=z9hG4bK-3230-3d42d8c86f8aa3d6d0194a4846511464
最大前锋:70
联系人:
内容长度:0
log4j:警告:找不到记录器的附加器(测试)。
log4j:警告请正确初始化log4j系统。
log4j:请参阅http://logging.apache.org/log4j/1.2/faq.html#noconfig 更多信息。
…….cseqCSeq:1个寄存器
SIP/2.0 401未经授权
Via:SIP/2.0/UDP localIP:52216;分支=z9hG4bK-3230-3d42d8c86f8aa3d6d0194a4846511464;接收=本地化;rport=52216
发件人:;标签=-1436906198
致:;标签=as24ab6bcf
呼叫ID:cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq:1寄存器
服务器:星号PBX 10.5.1
允许:邀请、确认、取消、选项、再见、参考、订阅、通知、信息、发布
支持:替换、定时器
WWW-Authenticate:Digest algorithm=MD5,realm=“xyz.com”,nonce=“6ac7ff34”
内容长度:0
注册sip:sipIP sip/2.0
呼叫ID:cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq:2寄存器
发件人:;标签=-1436906198
致:
Via:SIP/2.0/UDP localIP:52216;rport;分支机构=z9hG4bK-3230-a94c094a3aacfc40d0455de777b0ae26
最大前锋:70
联系人:
授权:Digest username=“username”,realm=“xyz.com”,nonce=“6ac7ff34”,uri=“sip:sipIP”,algorithm=MD5,response=“53231e4a2cd26604d8d2bc867b0e43e9”
内容长度:0
……..cseqCSeq:2寄存器
---------------------------注册人数:200--------------------
SIP/2.0 200正常
Via:SIP/2.0/UDP localIP:52216;分支机构=z9hG4bK-3230-a94c094a3aacfc40d0455de777b0ae26;接收=本地化;rport=52216
发件人:;标签=-1436906198
致:;标签=as24ab6bcf
呼叫ID:cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq:2寄存器
服务器:星号PBX 10.5.1
允许:邀请、确认、取消、选项、再见、参考、订阅、通知、信息、发布
支持:替换、定时器
有效期:240
联系人:;expires=240
日期:2015年4月30日星期四14:46:46 GMT
内容长度:0
对话框:createdgov.nist.javax.sip.stack。SIPDialog@79f65165
邀请sip:86940160@sipIPSIP/2.0
呼叫ID:cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq:3邀请
发件人:;标签=-1436906198
致:
Via:SIP/2.0/UDP localIP:52216;rport;分支=z9hG4bK-3230-c5512f65af9890c0798f1e5757ef1c57
最大前锋:70
内容类型:应用程序/sdp
联系人:
授权:Digest username=“username”,realm=“xyz.com”,nonce=“6ac7ff34”,uri=“sip:sipIP”,algorithm=MD5,response=“53231e4a2cd26604d8d2bc867b0e43e9”
内容长度:211
v=0
o=IP4本地化中的用户1 795808818 480847547
=-
c=在IP4中,P
t=0
m=音频8000 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101电话事件/8000
a=sendrecv
请求选项在stackwith服务器事务idnull处接收
请求选项在stackwith服务器事务idnull处接收
…….cseqCSeq:3邀请
…答案:1。。。。。。
SIP/2.0 401未经授权
Via:SIP/2.0/UDP localIP:52216;分支=z9hG4bK-3230-c5512f65af9890c0798f1e5757ef1c57;接收=本地化;rport=52216
发件人:;标签=-1436906198
致:;标签=as43ee81b7
呼叫ID:cdf4ef0fa1a145b1b07b632797f53fdb@localIP
CSeq:3邀请
服务器:星号PBX 10.5.1
允许:邀请、确认、取消、选项、再见、参考、订阅、通知、信息、发布
支持:替换、定时器
WWW-Authenticate:Digest algorithm=MD5,realm=“xyz.com”,nonce=“6ad3bcf0”
内容长度:0
移除标记后的响应:

------------------Invite 401--------------------

/nINVITE sip:86940160@sipIP:5060;maddr=sipIP SIP/2.0
Call-ID: 7128d7fc7109b0c1293dce9f6b2b9c7b@localIP.131
CSeq: 4 INVITE
From: <sip:username@sipIP>;tag=-515507368
To: <sip:86940160@sipIP>
Via: SIP/2.0/UDP localIP.131:52216;rport;branch=z9hG4bK-313339-453b043ba57ac51c5293cf17f8823071
Max-Forwards: 70
Content-Type: application/sdp
Contact: <sip:username@localIP.131:52216;transport=UDP>
Authorization: Digest username="username",realm="xyz.com",nonce="3cdd5016",uri="sip:86940160@sipIP:5060;maddr=sipIP",response="38b50cad69f74ba89fd63f78a1968acc",algorithm=MD5
Content-Length: 211

v=0
o=user1 795808818 480847547 IN IP4 localIP.131
s=-
c=IN IP4 localIP.131
t=0 0
m=audio 8000 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=sendrecv


Request OPTIONSreceived at stackwith server transaction idnull
................cseqCSeq: 4 INVITE

.....countInviteResponse: 2 ......
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP localIP.131:52216;branch=z9hG4bK-313339-453b043ba57ac51c5293cf17f8823071;received=localIP.131;rport=52216
From: <sip:username@sipIP>;tag=-515507368
To: <sip:86940160@sipIP>;tag=as5f585fd4
Call-ID: 7128d7fc7109b0c1293dce9f6b2b9c7b@localIP.131
CSeq: 4 INVITE
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
WWW-Authenticate: Digest algorithm=MD5,realm="xyz.com",nonce="6aa75c9f"
Content-Length: 0


------------------Invite 401--------------------

/nINVITE sip:86940160@sipIP:5060;maddr=sipIP SIP/2.0
Call-ID: 7128d7fc7109b0c1293dce9f6b2b9c7b@localIP.131
CSeq: 5 INVITE
From: <sip:username@sipIP>;tag=-515507368
To: <sip:86940160@sipIP>
Via: SIP/2.0/UDP localIP.131:52216;rport;branch=z9hG4bK-313339-5ed3ab3afc3b791c0af19470ae58813d
Max-Forwards: 70
Content-Type: application/sdp
Contact: <sip:username@localIP.131:52216;transport=UDP>
Authorization: Digest username="username",realm="xyz.com",nonce="6aa75c9f",uri="sip:86940160@sipIP:5060;maddr=sipIP",response="092fc083a66f19b5b995c8cbc8d5a8bc",algorithm=MD5
Content-Length: 211

v=0
o=user1 795808818 480847547 IN IP4 localIP.131
s=-
c=IN IP4 localIP.131
t=0 0
m=audio 8000 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=sendrecv
................cseqCSeq: 5 INVITE

.....countInviteResponse: 3 ......
------------------- Status Code: 100--------------------------
SIP/2.0 100 Trying
Via: SIP/2.0/UDP localIP.131:52216;branch=z9hG4bK-313339-5ed3ab3afc3b791c0af19470ae58813d;received=localIP.131;rport=52216
From: <sip:username@sipIP>;tag=-515507368
To: <sip:86940160@sipIP>
Call-ID: 7128d7fc7109b0c1293dce9f6b2b9c7b@localIP.131
CSeq: 5 INVITE
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
Contact: <sip:86940160@sipIP:5060>
Content-Length: 0


................cseqCSeq: 5 INVITE

.....countInviteResponse: 4 ......
------------------- Status Code: 183--------------------------
SIP/2.0 183 Session Progress
Via: SIP/2.0/UDP localIP.131:52216;branch=z9hG4bK-313339-5ed3ab3afc3b791c0af19470ae58813d;received=localIP.131;rport=52216
From: <sip:username@sipIP>;tag=-515507368
To: <sip:86940160@sipIP>;tag=as7fc2a07d
Call-ID: 7128d7fc7109b0c1293dce9f6b2b9c7b@localIP.131
CSeq: 5 INVITE
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
Contact: <sip:86940160@sipIP:5060>
Content-Type: application/sdp
Content-Length: 256

v=0
o=root 163700690 163700690 IN IP4 sipIP
s=Asterisk PBX 10.5.1
c=IN IP4 sipIP
t=0 0
m=audio 25036 RTP/AVP 8 101
a=rtpmap:8 PCMA/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=silenceSupp:off - - - -
a=ptime:20
a=sendrecv

Invite ID:z9hG4bK-313339-5ed3ab3afc3b791c0af19470ae58813d
CANCEL sip:86940160@sipIP:5060;maddr=sipIP SIP/2.0
Call-ID: 7128d7fc7109b0c1293dce9f6b2b9c7b@localIP.131
To: <sip:86940160@sipIP>
CSeq: 5 CANCEL
From: <sip:username@sipIP>;tag=-515507368
Via: SIP/2.0/UDP localIP.131:52216;rport;branch=z9hG4bK-313339-5ed3ab3afc3b791c0af19470ae58813d
Max-Forwards: 70
Content-Length: 0


................cseqCSeq: 5 CANCEL

-------------------Status Code: 481 ----------------------
SIP/2.0 481 Call/Transaction Does Not Exist
Via: SIP/2.0/UDP localIP.131:52216;branch=z9hG4bK-313339-5ed3ab3afc3b791c0af19470ae58813d;received=localIP.131;rport=52216
From: <sip:username@sipIP>;tag=-515507368
To: <sip:86940160@sipIP>;tag=as23aeabf5
Call-ID: 7128d7fc7109b0c1293dce9f6b2b9c7b@localIP.131
CSeq: 5 CANCEL
Server: Asterisk PBX 10.5.1
Allow: INVITE,ACK,CANCEL,OPTIONS,BYE,REFER,SUBSCRIBE,NOTIFY,INFO,PUBLISH
Supported: replaces,timer
Content-Length: 0
--------------邀请401--------------------
/nINVITE sip:86940160@sipIP:5060;maddr=sipIP SIP/2.0
呼叫ID:7128d7fc7109b0c1293dce9f6b2b9c7b@localIP.131
CSeq:4邀请
发件人:;标签=-515507368
致:
Via:SIP/2.0/UDP localIP.131:52216;rport;分支=z9hG4bK-313339-453b043ba57ac51c5293cf17f8823071
最大前锋:70
内容类型:应用程序/sdp
联系人:
授权:摘要username=“username”,realm=“xyz.com”,nonce=“3cdd5016”,uri=“sip:86940160@sipIP:5060;maddr=sipIP”,response=“38b50cad69f74ba89fd63f78a1968acc”,算法=MD5
内容长度:211
v=0
o=IP4本地化页131中的用户1 795808818 480847547
=-
c=在IP4中,第131页
t=0
m=音频8000 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101电话事件/8000
a=sendrecv
请求选项在stackwith服务器事务idnull处接收
…….cseqCSeq:4邀请
…答案:2。。。。。。
SIP/2.0 401未经授权
Via:SIP/2.0/UDP localIP.131:52216;分支=z9hG4bK-313339-453b043ba57ac51c5293cf17f8823071;收到=第131页;rport=52216
发件人:;标签=-515507368
致:;标签=as5f585fd4
呼叫ID:7128d7fc7109b0c1293dce9f6b2b9c7b@localIP.131
CSeq:4邀请
服务器:星号PBX 10.5.1
允许:邀请、确认、取消、选项、再见、参考、订阅、通知、信息、发布
支持:替换、定时器
WWW-Authenticate:Digest algorithm=MD5,realm=“xyz.com”,nonce=“6aa75c9f”
内容长度:0
------------------邀请401--------------------
/nINVITE sip:86940160@sipIP:5060;maddr=sipIP SIP/2.0
呼叫ID:7128d7fc7109b0c1293dce9f6b2b9c7b@localIP.131
CSeq:5邀请
发件人:;标签=-515507368
致:
Via:SIP/2.0/UDP localIP.131:52216;rport;分支=z9hG4bK-313339-5ed3ab3afc3b791c0af19470ae58813d
最大前锋:70
内容类型:应用程序/sdp
联系人:
授权:摘要username=“username”,realm=“xyz.com”,nonce=“6aa75c9f”,uri=“sip:86940160@sipIP:5060;maddr=sipIP”,response=“092fc083a66f19b5b995c8cbc8d5a8bc”,算法=MD5
内容长度:211
v=0
o=IP4本地化页131中的用户1 795808818 480847547
=-
c=在IP4中,第131页
t=0
m=音频8000 RTP/AVP 0 8 101
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:101电话事件/8000
a=sendrecv
…….cseqCSeq:5邀请
…答案:3。。。。。。
-------------------状态代码:100--------------------------
SIP/2.0 100
Via:SIP/2.0/UDP localIP.131:52216;分支=z9hG4bK-313339-5ed3ab3afc3b791c0af19470ae58813d;收到=第131页;rpo