0
votes

I'm sending SIP requests to Twilio SIP Trunk, using Node.js and Kirm/Sip module, I'm trying to cancel the call after receiving '180 Ringing' response.

The problem is that the [CANCEL] SIP request is sent but the server never replies with status '200 Canceling' like it should, instead it replies with a TCP [ACK] and the call remains ringing..

The Cancel request is a copy from the Invite request but changed the Method and CSec Method.

INVITE request:

INVITE sip:[email protected] SIP/2.0
From:  <sip:[email protected]>;tag=168502
To:  <sip:[email protected]>
Call-ID: 284466
CSeq: 969240 INVITE
Content-Type: application/sdp
Contact:  <sip:[email protected]>
Via: SIP/2.0/TCP 192.168.61.4:61244;branch=z9hG4bK847573
Content-Length: 363
Proxy-Authorization: Digest realm="sip.twilio.com",username="test",nonce="XXXX",uri="sip:[email protected]",nc=00000001,cnonce="XXXXXXX",qop=auth,opaque="XXXXXXX",response="XXXXXXX"

v=0
o=- 3700480907 3700480907 IN IP4 192.168.61.4
s=pjmedia
b=AS:84
t=0 0
a=X-nat:0
m=audio 4012 RTP/AVP 123 8 0 101
c=IN IP4 192.168.61.4
b=TIAS:64000
a=rtcp:4013 IN IP4 192.168.61.4
a=sendrecv
a=rtpmap:123 opus/48000/2
a=fmtp:123 maxplaybackrate=16000
a=rtpmap:8 PCMA/8000
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16

CANCEL request:

CANCEL sip:[email protected] SIP/2.0
CSeq: 969240 CANCEL
Call-ID: 284466
From:  <sip:[email protected]>;tag=168502
To:  <sip:[email protected]>
Via: SIP/2.0/TCP 192.168.61.4:61244;branch=z9hG4bK847573
Content-Length: 0

So any ideas?

Thanks

2
Your CANCEL looks perfectly valid. Is this the actual message. I assume there is no route header in INVITE. If it is in actual INVITE then copy to CANCEL also. - Sudhansu

2 Answers

2
votes

When receiving 180 Ringing To-tag should be set. Look for it in 180 Ringing To header. Something like "To: ;tag=9273782374" is expected.

You need to match CANCEL request with INVITE transaction so To tag should be set in CANCEL request.

CANCEL sip:[email protected] SIP/2.0
CSeq: 969240 CANCEL
Call-ID: 284466
From:  <sip:[email protected]>;tag=168502
To:  <sip:[email protected]>;tag=missingToTag
Via: SIP/2.0/TCP 192.168.61.4:61244;branch=z9hG4bK847573
Content-Length: 0
0
votes

I struggled with this for a while and just solved it when I saw this post.

You have to make sure that the tag from the "To:" field is the tag that is returned after the ACK to the invite request.

Flow goes like this:

Screenshot from Wireshark showing the SIP requests