PJSIP Bug

PF
Paul Fortescue
Mon, May 13, 2019 12:47 PM

I hope I'm posting this to the right place.

I have two SIP Softphones which use PJSIP

If i ring one from the other and then try to cancel the call, using

                    msip_call_end(callId);

It does not cancel. My SIP Server log shows why, basically the INVITE
branch is the same as the branch in the CANCEL request, but this is
rejected with a 401. PJSIP then re-sends the CANCEL with the addition of
AUTHORISATION but changes the branch, so it is rejected with a 481.

The Wireshark of the three relevant transactions is below:

  1. INVITE

INVITE sip:2222@192.168.33.62:51382;ob SIP/2.0
Via: SIP/2.0/UDP 192.168.33.62:5060;branch=z9hG4bK02000005
Record-Route: sip:192.168.33.62:5060;lr
Via: SIP/2.0/TCP
192.168.33.62:62679;rport;branch=z9hG4bKPja5c5bb630b3c44228dda833444253613;alias
Max-Forwards: 69
From: "Me" sip:1234@192.168.33.62;tag=35e96c8287b14cc09258673897bff13e
To: sip:2222@192.168.33.62
Contact: sip:1234@192.168.33.62:5060;transport=udp
Call-ID: 8dd1769a70c84b53a3cf58fe5c3ccda6
CSeq: 3875 INVITE
Route: sip:192.168.33.62;lr
Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY,
REFER, MESSAGE, OPTIONS
Supported: replaces, 100rel, timer, norefersub
Session-Expires: 1800
Min-SE: 90
User-Agent: XX SIP Bridge/3.17.3
Content-Type: application/sdp
Content-Length:   534

v=0
o=- 3766736270 3766736270 IN IP4 192.168.33.62
s=pjmedia
b=AS:1498
t=0 0
a=X-nat:0
m=audio 4000 RTP/AVP 0 8 9 3 104 99 98 97 11 10 96
c=IN IP4 192.168.33.62
b=TIAS:1411200
a=rtcp:4001 IN IP4 192.168.33.62
a=sendrecv
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:9 G722/8000
a=rtpmap:3 GSM/8000
a=rtpmap:104 iLBC/8000
a=fmtp:104 mode=30
a=rtpmap:99 speex/32000
a=rtpmap:98 speex/16000
a=rtpmap:97 speex/8000
a=rtpmap:11 L16/44100
a=rtpmap:10 L16/44100/2
a=rtpmap:96 telephone-event/8000
a=fmtp:96 0-16

  1. First CANCEL - note the branch is the same as the INVITE in this one:

CANCEL sip:2222@192.168.33.62 SIP/2.0
Via: SIP/2.0/TCP
192.168.33.62:56549;rport;branch=z9hG4bKPja5c5bb630b3c44228dda833444253613;alias
Max-Forwards: 70
From: "Me" sip:1234@192.168.33.62;tag=35e96c8287b14cc09258673897bff13e
To: sip:2222@192.168.33.62
Call-ID: 8dd1769a70c84b53a3cf58fe5c3ccda6
CSeq: 3875 CANCEL
Route: sip:192.168.33.62;lr
User-Agent: XX SIP Bridge/3.17.3
Content-Length:  0

  1. Second CANCEL - note the branch is ** NOT ** the same as the INVITE
    in this one:

!>!>P?CANCEL sip:2222@192.168.33.62 SIP/2.0
Via: SIP/2.0/TCP
192.168.33.62:56549;rport;branch=z9hG4bKPj5fbebf16cc88402eae5b953048d0425d;alias
Max-Forwards: 70
From: "Me" sip:1234@192.168.33.62;tag=35e96c8287b14cc09258673897bff13e
To: sip:2222@192.168.33.62
Call-ID: 8dd1769a70c84b53a3cf58fe5c3ccda6
CSeq: 3875 CANCEL
Route: sip:192.168.33.62;lr
User-Agent: XX SIP Bridge/3.17.3
Authorization: Digest username="1234", realm="192.168.33.62",
nonce="e29d903e21023824f92dd79b584cdeb0", uri="sip:2222@192.168.33.62",
response="9ed4fd1fb93c5d1398adf93ef6a69752", algorithm=MD5,
cnonce="9f888d576e7d439a8a073939a8a8ff00", opaque="0000001e", qop=auth,
nc=00000001
Content-Length:  0

I hope I'm posting this to the right place. I have two SIP Softphones which use PJSIP If i ring one from the other and then try to cancel the call, using                     msip_call_end(callId); It does not cancel. My SIP Server log shows why, basically the INVITE branch is the same as the branch in the CANCEL request, but this is rejected with a 401. PJSIP then re-sends the CANCEL with the addition of AUTHORISATION but changes the branch, so it is rejected with a 481. The Wireshark of the three relevant transactions is below: 1. INVITE INVITE sip:2222@192.168.33.62:51382;ob SIP/2.0 Via: SIP/2.0/UDP 192.168.33.62:5060;branch=z9hG4bK02000005 Record-Route: <sip:192.168.33.62:5060;lr> Via: SIP/2.0/TCP 192.168.33.62:62679;rport;branch=z9hG4bKPja5c5bb630b3c44228dda833444253613;alias Max-Forwards: 69 From: "Me" <sip:1234@192.168.33.62>;tag=35e96c8287b14cc09258673897bff13e To: <sip:2222@192.168.33.62> Contact: <sip:1234@192.168.33.62:5060;transport=udp> Call-ID: 8dd1769a70c84b53a3cf58fe5c3ccda6 CSeq: 3875 INVITE Route: <sip:192.168.33.62;lr> Allow: PRACK, INVITE, ACK, BYE, CANCEL, UPDATE, INFO, SUBSCRIBE, NOTIFY, REFER, MESSAGE, OPTIONS Supported: replaces, 100rel, timer, norefersub Session-Expires: 1800 Min-SE: 90 User-Agent: XX SIP Bridge/3.17.3 Content-Type: application/sdp Content-Length:   534 v=0 o=- 3766736270 3766736270 IN IP4 192.168.33.62 s=pjmedia b=AS:1498 t=0 0 a=X-nat:0 m=audio 4000 RTP/AVP 0 8 9 3 104 99 98 97 11 10 96 c=IN IP4 192.168.33.62 b=TIAS:1411200 a=rtcp:4001 IN IP4 192.168.33.62 a=sendrecv a=rtpmap:0 PCMU/8000 a=rtpmap:8 PCMA/8000 a=rtpmap:9 G722/8000 a=rtpmap:3 GSM/8000 a=rtpmap:104 iLBC/8000 a=fmtp:104 mode=30 a=rtpmap:99 speex/32000 a=rtpmap:98 speex/16000 a=rtpmap:97 speex/8000 a=rtpmap:11 L16/44100 a=rtpmap:10 L16/44100/2 a=rtpmap:96 telephone-event/8000 a=fmtp:96 0-16 2. First CANCEL - note the branch is the same as the INVITE in this one: CANCEL sip:2222@192.168.33.62 SIP/2.0 Via: SIP/2.0/TCP 192.168.33.62:56549;rport;branch=z9hG4bKPja5c5bb630b3c44228dda833444253613;alias Max-Forwards: 70 From: "Me" <sip:1234@192.168.33.62>;tag=35e96c8287b14cc09258673897bff13e To: <sip:2222@192.168.33.62> Call-ID: 8dd1769a70c84b53a3cf58fe5c3ccda6 CSeq: 3875 CANCEL Route: <sip:192.168.33.62;lr> User-Agent: XX SIP Bridge/3.17.3 Content-Length:  0 3. Second CANCEL - note the branch is ** NOT ** the same as the INVITE in this one: !>!>P?CANCEL sip:2222@192.168.33.62 SIP/2.0 Via: SIP/2.0/TCP 192.168.33.62:56549;rport;branch=z9hG4bKPj5fbebf16cc88402eae5b953048d0425d;alias Max-Forwards: 70 From: "Me" <sip:1234@192.168.33.62>;tag=35e96c8287b14cc09258673897bff13e To: <sip:2222@192.168.33.62> Call-ID: 8dd1769a70c84b53a3cf58fe5c3ccda6 CSeq: 3875 CANCEL Route: <sip:192.168.33.62;lr> User-Agent: XX SIP Bridge/3.17.3 Authorization: Digest username="1234", realm="192.168.33.62", nonce="e29d903e21023824f92dd79b584cdeb0", uri="sip:2222@192.168.33.62", response="9ed4fd1fb93c5d1398adf93ef6a69752", algorithm=MD5, cnonce="9f888d576e7d439a8a073939a8a8ff00", opaque="0000001e", qop=auth, nc=00000001 Content-Length:  0