SIP ACK 对话框为空

2024-01-09

我正在使用 JAIN SIP 在 java 中创建 SIP 客户端。

我已经成功注册并发送 INVITE,但是当将 ACK 发送回服务器时,我收到错误消息:

Cannot Create ACK - no remote Target

我检查了 Dialog 的值,它是空的

在 processResponce() 中,我得到的值也是 null

this.dialog = responseEvent.getClientTransaction().getDialog();

我将它传递给 ack(responseEvent.getResponse(),dialog)

request =this.dialog.createAck(((CSeqHeader)response.getHeader("CSeq")).getSeqNumber());
dialog.sendAck(request);

同样在 Register() 和 Call() 中

this.dialog = inviteTid.getDialog();

这里dialog的值也是null

我也尝试过

dialog = sipProvider.getNewDialog(inviteID);

但它给出的错误为

AUTOMATIC_DIALOG_SUPPORT is on

我是否必须初始化对话框或进行更多调用来设置其值?

如何实现ACK?

REGISTER sip:SipIP SIP/2.0
Call-ID: b83eb80b195f6802c283c5927fb6415a@localHost
CSeq: 1 REGISTER
From: <sip:username@SipIP>;tag=1626086046
To: <sip:username@SipIP>
Via: SIP/2.0/UDP localHost:52216;rport;branch=z9hG4bK-363935-33f876b2e3720a123b62c68fc23cfa68
Max-Forwards: 70
Contact: <sip:username@localHost:52216;transport=UDP>
Content-Length: 0

SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP localHost:52216;branch=z9hG4bK-363935-33f876b2e3720a123b62c68fc23cfa68;received=localHost;rport=52216
From: <sip:username@SipIP>;tag=1626086046
To: <sip:username@SipIP>;tag=as3c3695d2
Call-ID: b83eb80b195f6802c283c5927fb6415a@localHost
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="65dfb3ad"
Content-Length: 0


REGISTER sip:SipIP SIP/2.0
Call-ID: b83eb80b195f6802c283c5927fb6415a@localHost
CSeq: 2 REGISTER
From: <sip:username@SipIP>;tag=1626086046
To: <sip:username@SipIP>
Via: SIP/2.0/UDP localHost:52216;rport;branch=z9hG4bK-363935-150b07c1e9409d05aafaa7652859024a
Max-Forwards: 70
Contact: <sip:username@localHost:52216;transport=UDP>
Authorization: Digest username="username",realm="xyz.com",nonce="65dfb3ad",uri="sip:SipIP",algorithm=MD5,response="b34005eb8ded9180fb5f5667f1ee842d"
Content-Length: 0


---------------------------Registered200--------------------

SIP/2.0 200 OK
Via: SIP/2.0/UDP localHost:52216;branch=z9hG4bK-363935-    150b07c1e9409d05aafaa7652859024a;received=localHost;rport=52216
From: <sip:username@SipIP>;tag=1626086046
To: <sip:username@SipIP>;tag=as3c3695d2
Call-ID: b83eb80b195f6802c283c5927fb6415a@localHost
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@localHost:52216;transport=UDP>;expires=240
Date: Wed, 22 Apr 2015 23:52:44 GMT
Content-Length: 0


Dialog created: gov.nist.javax.sip.stack.SIPDialog@d15ad713
Dialog: gov.nist.javax.sip.stack.SIPDialog@d15ad713

INVITE sip:SipIP SIP/2.0
Call-ID: b83eb80b195f6802c283c5927fb6415a@localHost
CSeq: 3 INVITE
From: <sip:username@SipIP>;tag=1626086046
To: <sip:160@SipIP>
Via: SIP/2.0/UDP localHost:52216;rport;branch=z9hG4bK-363935-3d3a34f99499b96c6c1f709065ed4c85
Max-Forwards: 70
Content-Type: application/sdp
Contact: <sip:username@localHost:52216;transport=UDP>
Content-Length: 300

v=0
o=fraunhofer 392867480 292042336 IN IP4 localHost
s=-
c=IN IP4 localHost
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
------------------Invite 401--------------------

SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP localHost:52216;branch=z9hG4bK-363935-        3d3a34f99499b96c6c1f709065ed4c85;received=localHost;rport=52216
From: <sip:username@SipIP>;tag=1626086046
To: <sip:160@SipIP>;tag=as3c3695d2
Call-ID: b83eb80b195f6802c283c5927fb6415a@localHost
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="4c1d89c8"
Content-Length: 0


-------------------------Dialog:gov.nist.javax.sip.stack.SIPDialog@d15ad713
Dialog get Remote Target: null
javax.sip.SipException: Cannot create ACK - no remote Target!
at gov.nist.javax.sip.stack.SIPDialog.createAck(SIPDialog.java:3021)
at test.ack(test.java:507)
at test.processResponse(test.java:214)
at gov.nist.javax.sip.EventScanner.deliverEvent(EventScanner.java:296)
at gov.nist.javax.sip.EventScanner.run(EventScanner.java:519)
at java.lang.Thread.run(Thread.java:745)

具有更改的呼叫 ID 的新响应

REGISTER sip:SIPIP SIP/2.0
Call-ID: 01bb8e9788fc251f8d44f2c709542fa5@LOCALIP
CSeq: 1 REGISTER
From: <sip:username@SIPIP>;tag=2125326583
To: <sip:username@SIPIP>
Via: SIP/2.0/UDP LOCALIP:52216;rport;branch=z9hG4bK-3833-142aff6ad1e359c2b618eba23fa04453
Max-Forwards: 70
Contact: <sip:username@LOCALIP:52216;transport=UDP>
Content-Length: 0

SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP LOCALIP:52216;branch=z9hG4bK-3833-142aff6ad1e359c2b618eba23fa04453;received=LOCALIP;rport=52216
From: <sip:username@SIPIP>;tag=2125326583
To: <sip:username@SIPIP>;tag=as2e8e5e8d
Call-ID: 01bb8e9788fc251f8d44f2c709542fa5@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="6223df47"
Content-Length: 0


REGISTER sip:SIPIP SIP/2.0
Call-ID: 01bb8e9788fc251f8d44f2c709542fa5@LOCALIP
CSeq: 2 REGISTER
From: <sip:username@SIPIP>;tag=2125326583
To: <sip:username@SIPIP>
Via: SIP/2.0/UDP LOCALIP:52216;rport;branch=z9hG4bK-3833-36d48a4c062bbb9e83db9a12f36414b3
Max-Forwards: 70
Contact: <sip:username@LOCALIP:52216;transport=UDP>
Authorization: Digest username="username",realm="xyz.com",nonce="6223df47",uri="sip:SIPIP",algorithm=MD5,response="d4ac55bbc8dacb87f66cf9f4041af03c"
Content-Length: 0


---------------------------Registered200--------------------

SIP/2.0 200 OK
Via: SIP/2.0/UDP LOCALIP:52216;branch=z9hG4bK-3833-36d48a4c062bbb9e83db9a12f36414b3;received=LOCALIP;rport=52216
From: <sip:username@SIPIP>;tag=2125326583
To: <sip:username@SIPIP>;tag=as2e8e5e8d
Call-ID: 01bb8e9788fc251f8d44f2c709542fa5@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, 23 Apr 2015 08:38:28 GMT
Content-Length: 0


Dialog: createdgov.nist.javax.sip.stack.SIPDialog@977c31a5
INVITE sip:SIPIP SIP/2.0
Call-ID: a86cc90138ad50d9716664b7925cb205@LOCALIP
CSeq: 3 INVITE
From: <sip:username@SIPIP>;tag=2125326583
To: <sip:160@SIPIP>
Via: SIP/2.0/UDP LOCALIP:52216;rport;branch=z9hG4bK-            3833-0db5ef4b4e463aee4fa22c3379915d5e
Max-Forwards: 70
Content-Type: application/sdp
Contact: <sip:username@LOCALIP:52216;transport=UDP>
Content-Length: 300

v=0
o=fraunhofer 392867480 292042336 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
------------------Invite 401--------------------

SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP LOCALIP:52216;branch=z9hG4bK-   3833-0db5ef4b4e463aee4fa22c3379915d5e;received=LOCALIP;rport=52216
From: <sip:username@SIPIP>;tag=2125326583
To: <sip:160@SIPIP>;tag=as54bd3315
Call-ID: a86cc90138ad50d9716664b7925cb205@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="1e960014"
Content-Length: 0

呼叫(响应)

enterpublic void call(Response response) {
    try {
        cseq++;
        String callee = "160";
        current_process = cseq + "INVITE";
        ArrayList viaHeaders = new ArrayList();
        ViaHeader viaHeader = headerFactory.createViaHeader(localIP,
                rport, "udp", null);
        viaHeader.setRPort();
        viaHeaders.add(viaHeader);
        // The "Max-Forwards" header.
        MaxForwardsHeader maxForwardsHeader = headerFactory.createMaxForwardsHeader(70);
        // The "Call-Id" header.
        CallIdHeader callIdHeader = this.sipProvider.getNewCallId();;
        // The "CSeq" header.
        CSeqHeader cSeqHeader = headerFactory.createCSeqHeader(cseq, "INVITE");

        Address fromAddress = addressFactory.createAddress("sip:"
                + username + '@' + server);

        Address toAddress = addressFactory.createAddress("sip:"+callee+'@'+sipIP);

        FromHeader fromHeader = headerFactory.createFromHeader(
                fromAddress, String.valueOf(this.tag));
        // The "To" header.
        ToHeader toHeader = headerFactory.createToHeader(toAddress,
                null);

        ContentLengthHeader contentLength = headerFactory.createContentLengthHeader(211);
        ContentTypeHeader contentType = headerFactory.createContentTypeHeader("application", "sdp");

        String sdpData = "v=0\n" + 
                "o=user1 795808818 480847547 IN IP4 10.99.70.106\n" + 
                "s=-\n" + 
                "c=IN IP4 10.99.70.106\n" + 
                "t=0 0\n" + 
                "m=audio 8000 RTP/AVP 0 8 101\n" + 
                "a=rtpmap:0 PCMU/8000\n" + 
                "a=rtpmap:8 PCMA/8000\n" + 
                "a=rtpmap:101 telephone-event/8000\n" + 
                "a=sendrecv";
         byte[] contents = sdpData.getBytes();
         this.contactHeader = this.headerFactory
         .createContactHeader(contactAddress);

         URI requestURI = addressFactory.createURI("sip:"
                +callee+ '@'+ server); 

        request = this.messageFactory.createRequest(requestURI, Request.INVITE, 
                callIdHeader,cSeqHeader, fromHeader, toHeader, viaHeaders, maxForwardsHeader, contentType, contents);

        request.addHeader(contactHeader);
        request.addHeader(contentLength);
        test listener =this;
        if (response != null) {
            boolean retry = true;
            System.out.println("DEBUG: Response: "+response);
        }
        listener.inviteTid = sipProvider.getNewClientTransaction(request);


        if(dialog!= null && logger.isDebugEnabled()){
            logger.debug("Obtain dialog from ClientTransaction: automatic dialog support on");
//              System.out.println("Obtain dialog from ClientTransaction: automatic dialog support on");
        }
        if(dialog == null){
            //Automatic Dialog support turned off

            dialog = sipProvider.getNewDialog(inviteTid);

        }
        System.out.println("Dialog: created" + dialog);
        // send the request out.
        listener.inviteTid.sendRequest();

        this.dialog = this.inviteTid.getDialog();
 //         System.out.println("Dialog:" + dialog);

        // Send the request statelessly through the SIP provider.
        // this.sipProvider.sendRequest(request);
        System.out.println(request.toString());
        // Display the message in the text area.
        logger.debug("Request sent:\n" + "\n\n");
    } catch (Exception e) {
        // If an error occurred, display the error.
        e.printStackTrace();
        logger.debug("Request sent failed: " + e.getMessage() + "\n");
    }
}

无法创建 ACK 的日志 - 无远程目标

enter REGISTER sip:localIP SIP/2.0
Call-ID: [email protected] /cdn-cgi/l/email-protection
CSeq: 1 REGISTER
From: <sip:username@localIP>;tag=1825098223
To: <sip:username@localIP>
Via: SIP/2.0/UDP 10.99.136.136:52216;rport;branch=z9hG4bK-363735-0dd0a58b853bb23070f706fc3b058461
Max-Forwards: 70
Contact: <sip:[email protected] /cdn-cgi/l/email-protection:52216;transport=UDP>
Content-Length: 0


-----------StatusCode:401----------------------------
-----------currentREsponse:Unauthorized----------------------------
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 10.99.136.136:52216;branch=z9hG4bK-    363735-0dd0a58b853bb23070f706fc3b058461;received=10.99.136.136;rport=52216
From: <sip:username@localIP>;tag=1825098223
To: <sip:username@localIP>;tag=as78941717
Call-ID: [email protected] /cdn-cgi/l/email-protection
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="49a39764"
Content-Length: 0


REGISTER sip:localIP SIP/2.0
Call-ID: [email protected] /cdn-cgi/l/email-protection
CSeq: 2 REGISTER
From: <sip:username@localIP>;tag=1825098223
To: <sip:username@localIP>
Via: SIP/2.0/UDP 10.99.136.136:52216;rport;branch=z9hG4bK-363735-0a214e6d4a1bc50c0faf1657cf109e31
Max-Forwards: 70
Contact: <sip:[email protected] /cdn-cgi/l/email-protection:52216;transport=UDP>
Authorization: Digest username="username",realm="xyz.com",nonce="49a39764",uri="sip:localIP",algorithm=MD5,response="1af91bd8169339ec8c77decfab59fd21"
Content-Length: 0


-----------StatusCode:200----------------------------
-----------currentREsponse:OK----------------------------
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.99.136.136:52216;branch=z9hG4bK-    363735-0a214e6d4a1bc50c0faf1657cf109e31;received=10.99.136.136;rport=52216
From: <sip:username@localIP>;tag=1825098223
To: <sip:username@localIP>;tag=as78941717
Call-ID: [email protected] /cdn-cgi/l/email-protection
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:[email protected] /cdn-cgi/l/email-protection:52216;transport=UDP>;expires=240
Date: Fri, 24 Apr 2015 16:58:50 GMT
Content-Length: 0


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

SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.99.136.136:52216;branch=z9hG4bK-363735-0a214e6d4a1bc50c0faf1657cf109e31;received=10.99.136.136;rport=52216
From: <sip:username@localIP>;tag=1825098223
To: <sip:username@localIP>;tag=as78941717
Call-ID: [email protected] /cdn-cgi/l/email-protection
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:[email protected] /cdn-cgi/l/email-protection:52216;transport=UDP>;expires=240
Date: Fri, 24 Apr 2015 16:58:50 GMT
Content-Length: 0


DEBUG: Response: SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.99.136.136:52216;branch=z9hG4bK-    363735-0a214e6d4a1bc50c0faf1657cf109e31;received=10.99.136.136;rport=52216
From: <sip:username@localIP>;tag=1825098223
To: <sip:username@localIP>;tag=as78941717
Call-ID: [email protected] /cdn-cgi/l/email-protection
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:[email protected] /cdn-cgi/l/email-protection:52216;transport=UDP>;expires=240
Date: Fri, 24 Apr 2015 16:58:50 GMT
Content-Length: 0


Dialog: createdgov.nist.javax.sip.stack.SIPDialog@393895ed
INVITE sip:160@localIP SIP/2.0
Call-ID: [email protected] /cdn-cgi/l/email-protection
CSeq: 3 INVITE
From: <sip:username@localIP>;tag=1825098223
To: <sip:160@localIP>
Via: SIP/2.0/UDP 10.99.136.136:52216;rport;branch=z9hG4bK-363735-312eacb8db309d6c6794e2eb7adf8b92
Max-Forwards: 70
Content-Type: application/sdp
Contact: <sip:[email protected] /cdn-cgi/l/email-protection:52216;transport=UDP>
Authorization: Digest username="username",realm="xyz.com",nonce="49a39764",uri="sip:localIP",algorithm=MD5,response="1af91bd8169339ec8c77decfab59fd21"
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
-----------StatusCode:401----------------------------
-----------currentREsponse:Unauthorized----------------------------
------------------Invite 401--------------------

SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 10.99.136.136:52216;branch=z9hG4bK-    363735-312eacb8db309d6c6794e2eb7adf8b92;received=10.99.136.136;rport=52216
From: <sip:username@localIP>;tag=1825098223
To: <sip:160@localIP>;tag=as4f6f7f78
Call-ID: [email protected] /cdn-cgi/l/email-protection
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="7e048345"
Content-Length: 0


DEBUG: Response: SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 10.99.136.136:52216;branch=z9hG4bK-363735-312eacb8db309d6c6794e2eb7adf8b92;received=10.99.136.136;rport=52216
From: <sip:username@localIP>;tag=1825098223
To: <sip:160@localIP>;tag=as4f6f7f78
Call-ID: [email protected] /cdn-cgi/l/email-protection
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="7e048345"
Content-Length: 0


Dialog: createdgov.nist.javax.sip.stack.SIPDialog@393895ed
INVITE sip:160@localIP SIP/2.0
Call-ID: [email protected] /cdn-cgi/l/email-protection
CSeq: 4 INVITE
From: <sip:username@localIP>;tag=1825098223
To: <sip:160@localIP>
Via: SIP/2.0/UDP 10.99.136.136:52216;rport;branch=z9hG4bK-363735-dae4419c9405bb40dda573fe9c276518
Max-Forwards: 70
Content-Type: application/sdp
Contact: <sip:[email protected] /cdn-cgi/l/email-protection:52216;transport=UDP>
Authorization: Digest username="username",realm="xyz.com",nonce="49a39764",uri="sip:localIP",algorithm=MD5,response="1af91bd8169339ec8c77decfab59fd21"
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
-----------StatusCode:401----------------------------
-----------currentREsponse:Unauthorized----------------------------
------------------Invite 401--------------------

SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 10.99.136.136:52216;branch=z9hG4bK-363735-1a2fd8de5c389de950ecbb1a3d9a7d3e;received=10.99.136.136;rport=52216
From: <sip:username@localIP>;tag=1825098223
To: <sip:160@localIP>;tag=as22472833
Call-ID: [email protected] /cdn-cgi/l/email-protection
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="599cd63b"
Content-Length: 0


DEBUG: Response: SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 10.99.136.136:52216;branch=z9hG4bK-363735-1a2fd8de5c389de950ecbb1a3d9a7d3e;received=10.99.136.136;rport=52216
From: <sip:username@localIP>;tag=1825098223
To: <sip:160@localIP>;tag=as22472833
Call-ID: [email protected] /cdn-cgi/l/email-protection
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="599cd63b"
Content-Length: 0


Dialog: createdgov.nist.javax.sip.stack.SIPDialog@393895ed
INVITE sip:160@localIP SIP/2.0
Call-ID: [email protected] /cdn-cgi/l/email-protection
CSeq: 5 INVITE
From: <sip:username@localIP>;tag=1825098223
To: <sip:160@localIP>
Via: SIP/2.0/UDP 10.99.136.136:52216;rport;branch=z9hG4bK-363735-633d808b788771fa1e211672ddc3e903
Max-Forwards: 70
Content-Type: application/sdp
Contact: <sip:[email protected] /cdn-cgi/l/email-protection:52216;transport=UDP>
Authorization: Digest username="username",realm="xyz.com",nonce="49a39764",uri="sip:localIP",algorithm=MD5,response="1af91bd8169339ec8c77decfab59fd21"
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
-----------StatusCode:401----------------------------
-----------currentREsponse:Unauthorized----------------------------
-----------StatusCode:100----------------------------
-----------currentREsponse:Trying----------------------------
------------------- Status Code: 100--------------------------
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 10.99.136.136:52216;branch=z9hG4bK-363735-a872936256c40065a4b147d4981cc74a;received=10.99.136.136;rport=52216
From: <sip:username@localIP>;tag=1825098223
To: <sip:160@localIP>
Call-ID: [email protected] /cdn-cgi/l/email-protection
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:160@localIP:5060>
Content-Length: 0


-----------StatusCode:401----------------------------
-----------currentREsponse:Unauthorized----------------------------


Request OPTIONSreceived at stackwith server transaction idnull
-----------StatusCode:180----------------------------
-----------currentREsponse:Ringing----------------------------

SIP/2.0 180 Ringing
Via: SIP/2.0/UDP 10.99.136.136:52216;branch=z9hG4bK-363735-a872936256c40065a4b147d4981cc74a;received=10.99.136.136;rport=52216
From: <sip:username@localIP>;tag=1825098223
To: <sip:160@localIP>;tag=as78f593d4
Call-ID: [email protected] /cdn-cgi/l/email-protection
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:160@localIP:5060>
Content-Length: 0

-


Request OPTIONSreceived at stackwith server transaction idnull


Request OPTIONSreceived at stackwith server transaction idnull


Request OPTIONSreceived at stackwith server transaction idnull
-----------StatusCode:200----------------------------
-----------currentREsponse:OK----------------------------
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.99.136.136:52216;branch=z9hG4bK-363735-a872936256c40065a4b147d4981cc74a;received=10.99.136.136;rport=52216
From: <sip:username@localIP>;tag=1825098223
To: <sip:160@localIP>;tag=as78f593d4
Call-ID: [email protected] /cdn-cgi/l/email-protection
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:160@localIP:5060>
Content-Type: application/sdp
Content-Length: 256

v=0
o=root 698934329 698934329 IN IP4 localIP
s=Asterisk PBX 10.5.1
c=IN IP4 localIP
t=0 0
m=audio 23142 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

javax.sip.SipException: Cannot create ACK - no remote Target!
    at gov.nist.javax.sip.stack.SIPDialog.createAck(SIPDialog.java:3021)
    at test.processResponse(test.java:323)
    at gov.nist.javax.sip.EventScanner.deliverEvent(EventScanner.java:296)
    at gov.nist.javax.sip.EventScanner.run(EventScanner.java:519)
    at java.lang.Thread.run(Thread.java:745)
-----------StatusCode:200----------------------------
-----------currentREsponse:OK----------------------------
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.99.136.136:52216;branch=z9hG4bK-363735-a872936256c40065a4b147d4981cc74a;received=10.99.136.136;rport=52216
From: <sip:username@localIP>;tag=1825098223
To: <sip:160@localIP>;tag=as78f593d4
Call-ID: [email protected] /cdn-cgi/l/email-protection
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:160@localIP:5060>
Content-Type: application/sdp
Content-Length: 256

v=0
o=root 698934329 698934329 IN IP4 localIP
s=Asterisk PBX 10.5.1
c=IN IP4 localIP
t=0 0
m=audio 23142 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

javax.sip.SipException: Cannot create ACK - no remote Target!
    at gov.nist.javax.sip.stack.SIPDialog.createAck(SIPDialog.java:3021)
    at test.processResponse(test.java:323)
    at gov.nist.javax.sip.EventScanner.deliverEvent(EventScanner.java:296)
    at gov.nist.javax.sip.EventScanner.run(EventScanner.java:519)
    at java.lang.Thread.run(Thread.java:745)
-----------StatusCode:200----------------------------
-----------currentREsponse:OK----------------------------
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.99.136.136:52216;branch=z9hG4bK-363735-a872936256c40065a4b147d4981cc74a;received=10.99.136.136;rport=52216
From: <sip:username@localIP>;tag=1825098223
To: <sip:160@localIP>;tag=as78f593d4
Call-ID: [email protected] /cdn-cgi/l/email-protection
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:160@localIP:5060>
Content-Type: application/sdp
Content-Length: 256

v=0
o=root 698934329 698934329 IN IP4 localIP
s=Asterisk PBX 10.5.1
c=IN IP4 localIP
t=0 0
m=audio 23142 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

javax.sip.SipException: Cannot create ACK - no remote Target!
    at gov.nist.javax.sip.stack.SIPDialog.createAck(SIPDialog.java:3021)
    at test.processResponse(test.java:323)
    at gov.nist.javax.sip.EventScanner.deliverEvent(EventScanner.java:296)
    at gov.nist.javax.sip.EventScanner.run(EventScanner.java:519)
    at java.lang.Thread.run(Thread.java:745)


Request OPTIONSreceived at stackwith server transaction idnull
-----------StatusCode:200----------------------------
-----------currentREsponse:OK----------------------------
SIP/2.0 200 OK
Via: SIP/2.0/UDP 10.99.136.136:52216;branch=z9hG4bK-363735-a872936256c40065a4b147d4981cc74a;received=10.99.136.136;rport=52216
From: <sip:username@localIP>;tag=1825098223
To: <sip:160@localIP>;tag=as78f593d4
Call-ID: [email protected] /cdn-cgi/l/email-protection
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:160@localIP:5060>
Content-Type: application/sdp
Content-Length: 256

v=0
o=root 698934329 698934329 IN IP4 localIP
s=Asterisk PBX 10.5.1
c=IN IP4 localIP
t=0 0
m=audio 23142 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

javax.sip.SipException: Cannot create ACK - no remote Target!
    at gov.nist.javax.sip.stack.SIPDialog.createAck(SIPDialog.java:3021)
    at test.processResponse(test.java:323)
    at gov.nist.javax.sip.EventScanner.deliverEvent(EventScanner.java:296)
    at gov.nist.javax.sip.EventScanner.run(EventScanner.java:519)
    at java.lang.Thread.run(Thread.java:745)




Request OPTIONSreceived at stackwith server transaction idnull


Request BYEreceived at stackwith server transaction idnull
----------------Received a BYE-----------------------
 null TID


Request BYEreceived at stackwith server transaction idnull
----------------Received a BYE-----------------------
 null TID


Request BYEreceived at stackwith server transaction idnull
----------------Received a BYE-----------------------
     null TID

让我们尝试更详细一点。

我所做的是获取 JAIN SIP 1.2 下载中提供的示例 UAC 代码:JAIN SIP 的 Jenkins https://jsip.ci.cloudbees.com/job/jsip/并修改它以涵盖注册和初始邀请。

我已经使用 IMS 核心进行了测试,因此它可能与您使用 Asterisk PBX 的体验略有不同,特别是我不需要验证 INVITE。

在高层结构方面,我有:

一堂课(TestUAC)既是主类又实现了SipListener界面。

  1. 在 main 上,我初始化堆栈、设置侦听器、读取任何配置,最后调用sendRegister()这将发送第一个 REGISTER 并启动该过程。
  2. On processResponse() callback. Based on the method of the CSeq of the response, I candistinguish between:
    • 对注册的回应(processRegisterResponse())
    • 对 INVITE 的响应(processInviteResponse())
    • 对再见的回应(processByeResponse())
  3. On processRequest()和其他回调我只是有痕迹。

一般来说,我保留很少的信息作为对象属性:

  • 堆栈内容:参考sipFactory, sipProvider, sipStack, addressFactory, messageFactory, headerFactory
  • 有关我的身份信息以及我想与谁交谈的信息:

例如

   private String callingURI;
   private String calledURI;
   private String username;
   private String password;
   private Address fromNameAddress;
   private ContactHeader contactHeader;

此外,我还为 cseq 和(遵循 JAIN SIP 示例)保留一个递增计数器,并保存 ackRequest 的副本,用于回复重新传输的 200 OK。

// Save the created ACK request, to respond to retransmitted 2xx
private Request ackRequest;

private long cseq=1L;

正如我所说,processResponse()只是基于Cseq方法进行分布:

public void processResponse(ResponseEvent responseReceivedEvent) {
    System.out.println("Got a response");
    Response response = (Response) responseReceivedEvent.getResponse();
    CSeqHeader cseq = (CSeqHeader) response.getHeader(CSeqHeader.NAME);

    System.out.println("Response received : Status Code = "
            + response.getStatusCode() + " " + cseq);

    try {
        if(cseq.getMethod().equals(Request.REGISTER)) {
            processRegisterResponse(responseReceivedEvent);
        }
        else if(cseq.getMethod().equals(Request.INVITE)) {
            processInviteResponse(responseReceivedEvent);
        }
        else if(cseq.getMethod().equals(Request.BYE)) {
            processByeResponse(responseReceivedEvent);
        }
        else {
            System.out.println("Response to unexpected request");
        }
    } catch(Exception e)  {
        e.printStackTrace();
    }
}

The processRegisterResponse()区分 401 Unauthorized 和 200 OK 响应。在第一种情况下,它将触发发送带有身份验证的注册。在第二种情况下,它将请求发送 INVITE:

private void processRegisterResponse(ResponseEvent responseReceivedEvent) throws TransactionUnavailableException, ParseException, InvalidArgumentException, SipException, NoSuchAlgorithmException {
    Response response = (Response) responseReceivedEvent.getResponse();

    if(response.getStatusCode() == Response.UNAUTHORIZED) {
        sendRegister(response);
    }
    else if (response.getStatusCode() == Response.OK) {
        contactHeader=(ContactHeader)response.getHeader(ContactHeader.NAME);
        sendInvite();
    }               
}

现在,对于 sendInvite() (我将尝试将其提取到相关部分)。

private void sendInvite() throws ParseException, InvalidArgumentException, TransactionUnavailableException, SipException {

    // create To Header
    URI toAddress = addressFactory.createURI(calledURI);
    Address toNameAddress = addressFactory.createAddress(toAddress);
    ToHeader toHeader = headerFactory.createToHeader(toNameAddress,null);

    FromHeader fromHeader = headerFactory.createFromHeader(fromNameAddress, "12345");
    // Create ViaHeaders
    ArrayList<ViaHeader> viaHeaders = getViaHeaders();

    // Create a new CallId header
    CallIdHeader callIdHeader = sipProvider.getNewCallId();

    // Create a new Cseq header
    CSeqHeader cSeqHeader = headerFactory.createCSeqHeader(cseq,Request.INVITE);
    cseq++;

    // Create a new MaxForwardsHeader
    MaxForwardsHeader maxForwards = headerFactory.createMaxForwardsHeader(70);

    // Create the request.
    Request request = messageFactory.createRequest(toAddress,
            Request.INVITE, callIdHeader, cSeqHeader, fromHeader,
            toHeader, viaHeaders, maxForwards);

    request.addHeader(contactHeader);

    // at this point you should add the rest of the headers, content, etc.

    // Create the client transaction.
    ClientTransaction currentTid = sipProvider.getNewClientTransaction(request);
    // send the request out.
    currentTid.sendRequest();
}

最后,接下来发生的事情是我们将收到 INVITE 的 200 OK。这主要是来自 JAIN SLEE 示例的代码,我已将其移至processInviteResponse()(我将再次尝试将其提炼为基础)。

private void processInviteResponse(ResponseEvent responseReceivedEvent) throws SipException, InvalidArgumentException {
    Response response = (Response) responseReceivedEvent.getResponse();
    ClientTransaction 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);
    }
}

收到 200 OK 并发送 ACK 后,您可能应该考虑下一步做什么:例如,在 JAIN SLEE UAC 示例中,它启动一个TimerTask一段时间后发送再见。

您还可以在那里添加其他错误(或临时)响应的处理。但请记住,堆栈将自动确认(无需代码)最终的错误响应。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

SIP ACK 对话框为空 的相关文章

  • 在 mvn 命令中指定 pom.xml 并混合其他项目的目标

    我有多个问题 我可以在 mvn 命令中指定 pom xml 吗 在当前项目上执行 mvn 命令时 我可以混合另一个项目的目标吗 例如 mvn clean otherproject comple otherproject install ot
  • Java Runtime.getRuntime().freeMemory() 问题

    我搜索并看到了一些线程 但没有一个能够解决我遇到的具体问题 我正在尝试使用以下方式监视我的内存使用情况Runtime getRuntime freeMemory Runtime getRuntime maxMemory and Runtim
  • 通过SOCKS代理连接Kafka

    我有一个在 AWS 上运行的 Kafka 集群 我想用标准连接到集群卡夫卡控制台消费者从我的应用程序服务器 应用程序服务器可以通过 SOCKS 代理访问互联网 无需身份验证 如何告诉 Kafka 客户端通过代理进行连接 我尝试了很多事情 包
  • 使用 Ant 将非代码资源添加到 jar 文件

    我正在将 java 应用程序打包成 jar 文件 我正在使用 ant 和 eclipse 我实际上需要在 jar 中直接在根文件夹下包含几个单独的非代码文件 xml 和 txt 文件 而不是与代码位于同一位置 我正在尝试使用includes
  • 打印星号的 ASCII 菱形

    我的程序打印出这样的钻石 但只有当参数或菱形的每一面为4 例如如果我输入6 底部三角形的间距是错误的 我一直在试图找出答案 当参数改变时 底部的三角形不会改变 只有顶部的三角形会改变 它只适用于输入4 public static void
  • Java:在 eclipse 中导出到 .jar 文件

    我正在尝试将 Eclipse 中的程序导出到 jar 文件 在我的项目中 我添加了一些图片和 PDF s 当我导出到 jar 文件时 似乎只有main已编译并导出 我的意愿是如果可能的话将所有内容导出到 jar 文件 因为这样我想将其转换为
  • Spring RestTemplate 使用 cookie 遵循重定向

    最近我遇到了一个问题 我需要做一个GET请求远程服务 我假设使用一个简单的 servlet 并且 RestTemplate 返回Too many redirects 经过一番调查 似乎对指定远程服务发出的第一个请求实际上只是一个 302 重
  • Spring Data JPA 选择不同

    我有一个情况 我需要建立一个select distinct a address from Person a 其中地址是 Person 内的地址实体 类型的查询 我正在使用规范动态构建我的 where 子句并使用findAll Specifi
  • 如何在代理后面安装 Eclipse Neon

    对于 Neon Eclipse 附带了一个安装程序 我在安装程序中找不到任何配置菜单 我的java版本是 java version java version 1 8 0 72 Java TM SE Runtime Environment b
  • Kotlin 未解决的参考:CLI 上 gradle 的 println

    放一个printlnkotlin 函数返回之前的语句会崩溃 堆栈跟踪 thufir dur NetBeansProjects kotlin thufir dur NetBeansProjects kotlin gradle clean bu
  • 如何根据运行的 jar 的结果让我的 ant 任务通过或失败?

    我正在运行 CrossCheck 无浏览器 js 单元测试 作为 ant 脚本的一部分 如果 CrossCheck 测试失败 我希望 ant 报告失败 这是 build xml 中的相关部分
  • 如何使用 Hibernate (EntityManager) 或 JPA 调用 Oracle 函数或过程

    我有一个返回 sys refcursor 的 Oracle 函数 当我使用 Hibernate 调用该函数时 出现以下异常 Hibernate call my function org hibernate exception Generic
  • 生成的序列以 1 开头,而不是注释中设置的 1000

    我想请求一些有关 Hibernate 创建的数据库序列的帮助 我有这个注释 下面的代码 在我的实体类中 以便为合作伙伴表提供单独的序列 我希望序列以 1000 开头 因为我在部署期间使用 import sql 将测试数据插入数据库 并且我希
  • 如何避免 ArrayIndexOutOfBoundsException 或 IndexOutOfBoundsException? [复制]

    这个问题在这里已经有答案了 如果你的问题是我得到了java lang ArrayIndexOutOfBoundsException在我的代码中 我不明白为什么会发生这种情况 这意味着什么以及如何避免它 这应该是最全面的典范 https me
  • 了解joda时间PeriodFormatter

    我以为我明白了 但显然我不明白 你能帮我通过这些单元测试吗 Test public void second assertEquals 00 00 01 OurDateTimeFormatter format 1000 Test public
  • 内部存储的安全性如何?

    我需要的 对于 Android 我需要永久保存数据 但也能够编辑 并且显然是读取 它 用户不应访问此数据 它可以包含诸如高分之类的内容 用户不得对其进行编辑 我的问题 我会 并且已经 使用过Internal Storage 但我不确定它实际
  • HashMap 值需要不可变吗?

    我知道 HashMap 中的键需要是不可变的 或者至少确保它们的哈希码 hashCode 不会改变或与另一个具有不同状态的对象发生冲突 但是 HashMap中存储的值是否需要与上面相同 为什么或者为什么不 这个想法是能够改变值 例如在其上调
  • Resteasy 可以查看 JAX-RS 方法的参数类型吗?

    我们使用 Resteasy 3 0 9 作为 JAX RS Web 服务 最近切换到 3 0 19 我们开始看到很多RESTEASY002142 Multiple resource methods match request警告 例如 我们
  • 使用按钮作为列表的渲染器

    我想使用一个更复杂的渲染器 其中包含列表的多个组件 更准确地说 类似于this https stackoverflow com questions 10840498 java swing 1 6 textinput like firefox
  • 如何使用play框架上传多个文件?

    我在用play framework 2 1 2 使用java我正在创建视图来上传多个文件 我的代码在这里 form action routes upload up enctype gt multipart form data

随机推荐

  • 打开像 Whatsapp 这样的对话框时显示动画?

    我想打开用户信息的对话框并显示动画 就像 Whatsapp 所做的那样 任何想法 先感谢您 看看这个开源库FabDialogMorph https github com hujiaweibujidao FabDialogMorph Here
  • 将 Json 映射到 Angular 对象

    我有以下 JSON 数据 columns table black list name id datatype uuid table black list name emailid datatype varchar table black l
  • SQL 帮助:使用嵌套 SELECT 计算单个查询中的行数

    我正在寻找一种更好的方法来执行以下查询 我有一个看起来像这样的表 game id home team id away team id 1 100 200 2 200 300 3 200 400 4 300 100 5 100 400 我想编
  • 在 AWS ECS 上的 Docker 映像中运行 CloudWatch Agent 失败

    对于这个问题 我对 Docker 和 AWS 还比较陌生 目标是创建一个使用基本 Laravel 应用程序运行 Apache 和 PHP 的单个 AWS ECS 实例 我想运行 CloudWatch 代理将所有日志发送到 CloudWatc
  • 在 Ajax 查询中使用预输入时出现 ember-select-2 问题

    我在用着余烬 选择 2 https istefo github io ember select 2 examples作为 ember 应用程序中的预输入 问题是我可以从服务器获取数据 但数据没有显示在下拉列表中 任何帮助将不胜感激 提前致谢
  • R 中 Stata 的 xtlogit (fe, re) 等效项?

    Stata 允许通过以下方式指定逻辑回归的固定效应和随机效应xtlogit http www stata com manuals13 xtxtlogit pdf fe and xtlogit http www stata com manua
  • 如何在 Atom 中替换换行符?

    在 Atom 中 如果我在搜索和替换工具上激活正则表达式模式 它可以找到换行符 n 但是当我尝试替换它们时 它们仍然存在 有没有办法替换 Atom 中的换行符字符串 看起来 Atom 匹配换行符为 r n但仅替换时表现不一致 n什么也没有
  • Visual Studio 生成的 Dockerfile 不适用于手动 docker 构建

    我想对现有的 NET core 5 应用程序进行 dockerize 并使用容器工具生成 Dockerfile 当我使用 Visual Studio 2022 进行调试时 它可以工作 但是当我使用命令手动运行它时docker build t
  • 如何用Python同时记录鼠标和键盘的移动?

    我想创建一个函数来记录鼠标和键盘事件 直到按下特定的键 然后一起重播它们 我认为这可以通过keyboard and mouse模块 在之前的一个问题中 我问过如何记录按下按键之前的鼠标移动 https stackoverflow com q
  • 带有透明居中箭头的边框

    我正在尝试用 a 来设计 div 的样式具有向下箭头的底部边框 div 中将包含图像 并且不应有上边框 右边框或左边框 向下箭头的填充应该与 div 相同或透明 我已经能够使用下面的代码让它大部分工作 hero position relat
  • 无法在节点和运行时之间转换参数“tx”:解码字段调用时出错

    当我想使用基于基板的链中内置的方法以及自定义类型时 我收到以下错误 2020 04 13 21 03 01 RPC CORE submitAndWatchExtrinsic extrinsic Extrinsic ExtrinsicStat
  • 图 - 具有顶点权重的最短路径

    这是一个消费税 在某些图问题中 顶点可以有权重而不是 或者除了边的权重之外 设 Cv 为顶点的成本 v 和 C x y 边 x y 的成本 这个问题大家关心 寻找图 G 中顶点 a 和 b 之间最便宜的路径 路径的成本是边和顶点的成本之和
  • 使用 ImageDataGenerator 时的 Keras 分割训练测试集

    我有一个目录 其中包含图像的子文件夹 根据标签 我想在 Keras 中使用 ImageDataGenerator 时将这些数据拆分为训练集和测试集 虽然 keras 中的 model fit 有用于指定分割的参数validation spl
  • 一级缓存和二级缓存有什么区别?

    我知道l1和l2缓存是多级缓存中的级别 我想知道每一级缓存放置在哪里 以及允许的最大缓存级别是多少 这两者都取决于CPU 有些CPU根本没有高速缓存 有些CPU在芯片上有L1高速缓存 而L2高速缓存在同一芯片上的单独芯片上 甚至在单独的芯片
  • 如何将图像文件保存在 Postgres 数据库上?

    出于学习目的 我正在使用 Python Flask 创建一个网站 我想从数据库中恢复图像并将其显示在屏幕上 但一步一步来 我首先不知道如何将图像保存在我的数据库中 我的搜索只显示我必须使用bytea输入我的数据库 然后我得到我的图像并以某种
  • 尝试比较两个 csv 文件并将差异写入输出

    我正在开发一个脚本 它获取 2 个 csv 文件之间的差异 并生成一个新的 csv 文件作为具有差异的输出 但前提是两个输入文件之间的相同 2 行 指行号 包含不同的数据 例如文件 1 中的第 3 行有 mike 篮球运动员 文件 2 中的
  • 如何在 Log 中模拟方法 e

    这里 Utils java 是我要测试的类 以下是在 UtilsTest 类中调用的方法 即使我嘲笑 Log e 方法 如下所示 Before public void setUp when Log e any String class an
  • 从 np.fft 计算幅度

    我似乎使用 np fft fft 计算原始波的不正确振幅 显示了 fft 的图 您可以看到显示的幅度约为 3 和 1 5 但如果您查看代码 我将使用幅度 7 和 3 来生成信号 该图应该有两个尖峰 在 x 13 处达到 y 3 在 x 15
  • 浏览器历史记录管理

    我正在尝试找到一种干净的解决方案 以最有效的方式处理浏览器历史记录 我正在使用 GWT 但这个问题确实比这更普遍 这是我的情况 我认为这是相当标准的 我有一个 Web 应用程序 它有几个不同的页面 位置 位置 无论你想怎么称呼它 我会显示这
  • SIP ACK 对话框为空

    我正在使用 JAIN SIP 在 java 中创建 SIP 客户端 我已经成功注册并发送 INVITE 但是当将 ACK 发送回服务器时 我收到错误消息 Cannot Create ACK no remote Target 我检查了 Dia