On hangup from sip phone 603(declined) getting translated into 503(service unavailable) to twilio sip trunk

Hi, I am using Asterisk 15.5. So whenever an sip phone hangup without accepting the call, It is sending 603(Declined) response to asterisk but asterisk is sending 503(service unavailable) response to twilio sip trunk which is causing of twilio sip trunk send again INVITE request and RINGING is coming again even after hangup from sip phone. How can this issue be resolved.

I am posting logs that I have received on asterisk console.

<— Transmitting SIP response (863 bytes) to TLS:54.172.60.1:35987 —>
SIP/2.0 180 Ringing
Via: SIP/2.0/TLS 54.172.60.1:5061;rport=35987;received=54.172.60.1;branch=z9hG4bK6b57.03e9fa07.0
Via: SIP/2.0/UDP 172.18.9.29:5060;rport=5060;received=172.18.9.29;branch=z9hG4bKd4b69fd6-df46-4cc7-b806-47e8261ccfea_6772d868_444-9472143413046765072
Record-Route: sip:54.172.60.1:5061;transport=tls;lr;r2=on
Record-Route: sip:54.172.60.1:5060;lr;r2=on
Call-ID: d151890aaba49d2659be85e97e00523d@0.0.0.0
From: “Anonymous” sip:Anonymous@zemoso-trial.pstn.twilio.com;tag=51477279_6772d868_d4b69fd6-df46-4cc7-b806-47e8261ccfea
To: sip:+16173000430@34.222.155.151;tag=10fb8c32-f1d1-40a5-ae9b-c8799feea153
CSeq: 7077 INVITE
Server: Asterisk PBX 15.5.0
Contact: sip:34.222.155.151:5061;transport=TLS
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Content-Length: 0

<— Received SIP response (447 bytes) from WSS:157.44.68.155:62289 —>
SIP/2.0 603 Decline
Via: SIP/2.0/WSS 172.31.46.5:8089;rport=8089;branch=z9hG4bKPjc7b2152f-7af6-41c2-a4dc-fa14de464abb;alias
From: "Anonymous"sip:Anonymous@ip-172-31-46-5.us-west-2.compute.internal;tag=1acde080-2e10-4272-97a8-618d88be6881
To: sips:sipML5@157.44.68.155;rtcweb-breaker=no;tag=dGInPRoTf30TPI06Deze
Call-ID: 571b4205-fd8d-4e00-8942-f48b8551a065
CSeq: 25514 INVITE
Content-Length: 0
Reason: SIP; cause=603; text=“Decline”

<— Transmitting SIP request (507 bytes) to WSS:157.44.68.155:62289 —>
ACK sips:sipML5@157.44.68.155:62289;transport=ws;rtcweb-breaker=no SIP/2.0
Via: SIP/2.0/WSS 172.31.46.5:8089;rport;branch=z9hG4bKPjc7b2152f-7af6-41c2-a4dc-fa14de464abb;alias
From: “Anonymous” sip:Anonymous@ip-172-31-46-5.us-west-2.compute.internal;tag=1acde080-2e10-4272-97a8-618d88be6881
To: sips:sipML5@157.44.68.155;rtcweb-breaker=no;tag=dGInPRoTf30TPI06Deze
Call-ID: 571b4205-fd8d-4e00-8942-f48b8551a065
CSeq: 25514 ACK
Max-Forwards: 70
User-Agent: Asterisk PBX 15.5.0
Content-Length: 0

== Everyone is busy/congested at this time (1:0/0/1)
– Auto fallthrough, channel ‘PJSIP/twilio0-0000000c’ status is ‘CHANUNAVAIL’
<— Transmitting SIP response (849 bytes) to TLS:54.172.60.1:35987 —>
SIP/2.0 503 Service Unavailable
Via: SIP/2.0/TLS 54.172.60.1:5061;rport=35987;received=54.172.60.1;branch=z9hG4bK6b57.03e9fa07.0
Via: SIP/2.0/UDP 172.18.9.29:5060;rport=5060;received=172.18.9.29;branch=z9hG4bKd4b69fd6-df46-4cc7-b806-47e8261ccfea_6772d868_444-9472143413046765072
Record-Route: sip:54.172.60.1:5061;transport=tls;lr;r2=on
Record-Route: sip:54.172.60.1:5060;lr;r2=on
Call-ID: d151890aaba49d2659be85e97e00523d@0.0.0.0
From: “Anonymous” sip:Anonymous@zemoso-trial.pstn.twilio.com;tag=51477279_6772d868_d4b69fd6-df46-4cc7-b806-47e8261ccfea
To: sip:+16173000430@34.222.155.151;tag=10fb8c32-f1d1-40a5-ae9b-c8799feea153
CSeq: 7077 INVITE
Server: Asterisk PBX 15.5.0
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Reason: Q.850;cause=34
Content-Length: 0

<— Received SIP request (461 bytes) from TLS:54.172.60.1:35987 —>
ACK sip:+16173000430@34.222.155.151;transport=tls SIP/2.0
Via: SIP/2.0/TLS 54.172.60.1:5061;branch=z9hG4bK6b57.03e9fa07.0
From: “Anonymous” sip:Anonymous@zemoso-trial.pstn.twilio.com;tag=51477279_6772d868_d4b69fd6-df46-4cc7-b806-47e8261ccfea
Call-ID: d151890aaba49d2659be85e97e00523d@0.0.0.0
To: sip:+16173000430@34.222.155.151;tag=10fb8c32-f1d1-40a5-ae9b-c8799feea153
CSeq: 7077 ACK
Max-Forwards: 70
User-Agent: Twilio Gateway
Content-Length: 0

<— Received SIP request (1455 bytes) from TLS:54.172.60.2:43735 —>
INVITE sip:+16173000430@34.222.155.151;transport=tls SIP/2.0
Record-Route: sip:54.172.60.2:5061;transport=tls;r2=on;lr
Record-Route: sip:54.172.60.2:5060;r2=on;lr
From: “Anonymous” sip:Anonymous@zemoso-trial.pstn.twilio.com;tag=79189298_6772d868_48edd39a-ebd1-4f7f-952a-04c4fb843ffb
To: sip:+16173000430@34.222.155.151;transport=tls
CSeq: 25455 INVITE
Max-Forwards: 62
P-Asserted-Identity: sip:+17607058888@4.55.13.227:5060
Privacy: id
Diversion: sip:+16173000430@public-vip.us1.twilio.com;reason=unconditional
Call-ID: 33e73869790c6d331db804894d141076@0.0.0.0
Via: SIP/2.0/TLS 54.172.60.2:5061;branch=z9hG4bKabd9.bb1b95e6.0
Via: SIP/2.0/UDP 172.18.53.80:5060;rport=5060;received=172.18.53.80;branch=z9hG4bK48edd39a-ebd1-4f7f-952a-04c4fb843ffb_6772d868_494-8139753403888067550
Contact: “Anonymous” sip:Anonymous@172.18.53.80:5060;transport=udp
Allow: INVITE,ACK,CANCEL,BYE,OPTIONS,REFER,NOTIFY
User-Agent: Twilio Gateway
X-Twilio-AccountSid: ACcabca62b57087f0853b63039647b8bc5
Content-Type: application/sdp
X-Twilio-CallSid: CAb05005eec56ba0b35f9b341904e414c7
Content-Length: 339

v=0
o=root 855225690 855225690 IN IP4 172.18.135.100
s=Twilio Media Gateway
c=IN IP4 34.203.250.154
t=0 0
m=audio 17622 RTP/SAVP 0 101
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:M2UIz+EgShfZZlsGLhwsDQyUjU7aneguarB4nwlV
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv

== Setting global variable ‘SIPDOMAIN’ to ‘34.222.155.151’
<— Transmitting SIP response (663 bytes) to TLS:54.172.60.2:43735 —>
SIP/2.0 100 Trying
Via: SIP/2.0/TLS 54.172.60.2:5061;rport=43735;received=54.172.60.2;branch=z9hG4bKabd9.bb1b95e6.0
Via: SIP/2.0/UDP 172.18.53.80:5060;rport=5060;received=172.18.53.80;branch=z9hG4bK48edd39a-ebd1-4f7f-952a-04c4fb843ffb_6772d868_494-8139753403888067550
Record-Route: sip:54.172.60.2:5061;transport=tls;lr;r2=on
Record-Route: sip:54.172.60.2:5060;lr;r2=on
Call-ID: 33e73869790c6d331db804894d141076@0.0.0.0
From: “Anonymous” sip:Anonymous@zemoso-trial.pstn.twilio.com;tag=79189298_6772d868_48edd39a-ebd1-4f7f-952a-04c4fb843ffb
To: sip:+16173000430@34.222.155.151
CSeq: 25455 INVITE
Server: Asterisk PBX 15.5.0
Content-Length: 0

-- Executing [+16173000430@twilio-incoming:1] NoOp("PJSIP/twilio0-0000000e", "") in new stack
-- Executing [+16173000430@twilio-incoming:2] Set("PJSIP/twilio0-0000000e", "user=sipML5") in new stack
-- Executing [+16173000430@twilio-incoming:3] Set("PJSIP/twilio0-0000000e", "callerId=Anonymous") in new stack
-- Executing [+16173000430@twilio-incoming:4] Set("PJSIP/twilio0-0000000e", "uid=IN-16173000430-20122019-08:14:10") in new stack
-- Executing [+16173000430@twilio-incoming:5] Set("PJSIP/twilio0-0000000e", "MESSAGE(body)=IN-16173000430-20122019-08:14:10") in new stack
-- Executing [+16173000430@twilio-incoming:6] MessageSend("PJSIP/twilio0-0000000e", "pjsip:sipML5") in new stack
-- Executing [+16173000430@twilio-incoming:7] Set("PJSIP/twilio0-0000000e", "language=en-US") in new stack
-- Executing [+16173000430@twilio-incoming:8] Set("PJSIP/twilio0-0000000e", "agentId=") in new stack
-- Executing [+16173000430@twilio-incoming:9] Set("PJSIP/twilio0-0000000e", "recordKey=") in new stack
-- Executing [+16173000430@twilio-incoming:10] Set("PJSIP/twilio0-0000000e", "incoming=true") in new stack
-- Executing [+16173000430@twilio-incoming:11] Set("PJSIP/twilio0-0000000e", "DENOISE(rx)=on") in new stack
-- Executing [+16173000430@twilio-incoming:12] Set("PJSIP/twilio0-0000000e", "TALK_DETECT(set)=,2500") in new stack
-- Executing [+16173000430@twilio-incoming:13] Dial("PJSIP/twilio0-0000000e", "PJSIP/sipML5") in new stack

<— Transmitting SIP request (620 bytes) to WSS:157.44.68.155:62289 —>
MESSAGE sips:sipML5@157.44.68.155:62289;transport=ws;rtcweb-breaker=no SIP/2.0
Via: SIP/2.0/WSS 172.31.46.5:8089;rport;branch=z9hG4bKPjef578f52-7fee-4a57-bcca-6f68441a8703;alias
From: sip:sipML5@ip-172-31-46-5.us-west-2.compute.internal;tag=2b72bda1-6c92-4cbd-9dae-68874b4ff2e2
To: sips:sipML5@157.44.68.155;rtcweb-breaker=no
Contact: sips:sipML5@ip-172-31-46-5.us-west-2.compute.internal:5060;transport=ws
Call-ID: 8cf8ea1b-70c7-4b58-b201-5fe35294a14f
CSeq: 17894 MESSAGE
Max-Forwards: 70
User-Agent: Asterisk PBX 15.5.0
Content-Type: text/plain
Content-Length: 32

IN-16173000430-20122019-08:14:10
– Called PJSIP/sipML5
== DTLS ECDH initialized (automatic), faster PFS enabled
<— Transmitting SIP request (1891 bytes) to WSS:157.44.68.155:62289 —>
INVITE sips:sipML5@157.44.68.155:62289;transport=ws;rtcweb-breaker=no SIP/2.0
Via: SIP/2.0/WSS 172.31.46.5:8089;rport;branch=z9hG4bKPj55a2fe4a-7c7c-462b-9fb6-32ebc78180d7;alias
From: “Anonymous” sip:Anonymous@ip-172-31-46-5.us-west-2.compute.internal;tag=c1c9e03f-fd78-4d06-9438-cc7736d6ebcb
To: sips:sipML5@157.44.68.155;rtcweb-breaker=no
Contact: sips:asterisk@ip-172-31-46-5.us-west-2.compute.internal:5060;transport=ws
Call-ID: eb0b0146-5f27-4be1-b328-31fea36e1051
CSeq: 25135 INVITE
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Diversion: sip:+16173000430@ip-172-31-46-5.us-west-2.compute.internal;reason=unconditional
Max-Forwards: 70
User-Agent: Asterisk PBX 15.5.0
Content-Type: application/sdp
Content-Length: 995

v=0
o=- 1023437161 1023437161 IN IP4 172.31.46.5
s=Asterisk
c=IN IP4 172.31.46.5
t=0 0
m=audio 15896 UDP/TLS/RTP/SAVPF 0 101
a=connection:new
a=setup:actpass
a=fingerprint:SHA-256 BD:C5:49:87:9B:FE:32:6A:44:A5:44:BD:5B:0E:94:3D:D8:F8:4B:9E:AC:9D:FE:B4:B5:FF:1E:02:2C:AA:B5:85
a=ice-ufrag:645eec3321fd968c242bc60515b590ec
a=ice-pwd:6d0534c904a0ae731c9a67d66edd04f0
a=candidate:H31d14ede 1 UDP 2130706431 fe80::7e:35ff:fe68:e444 15896 typ host
a=candidate:Hac1f2e05 1 UDP 2130706431 172.31.46.5 15896 typ host
a=candidate:S22de9b97 1 UDP 1694498815 34.222.155.151 15896 typ srflx raddr 172.31.46.5 rport 15896
a=candidate:H31d14ede 2 UDP 2130706430 fe80::7e:35ff:fe68:e444 15897 typ host
a=candidate:Hac1f2e05 2 UDP 2130706430 172.31.46.5 15897 typ host
a=candidate:S22de9b97 2 UDP 1694498814 34.222.155.151 15897 typ srflx raddr 172.31.46.5 rport 15897
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
a=rtcp-mux

<— Received SIP response (430 bytes) from WSS:157.44.68.155:62289 —>
SIP/2.0 481 Dialog/Transaction Does Not Exist
Via: SIP/2.0/WSS 172.31.46.5:8089;rport=8089;branch=z9hG4bKPjc7b2152f-7af6-41c2-a4dc-fa14de464abb;alias
From: "Anonymous"sip:Anonymous@ip-172-31-46-5.us-west-2.compute.internal;tag=1acde080-2e10-4272-97a8-618d88be6881
To: sips:sipML5@157.44.68.155;rtcweb-breaker=no;tag=dGInPRoTf30TPI06Deze
Call-ID: 571b4205-fd8d-4e00-8942-f48b8551a065
CSeq: 25514 ACK
Content-Length: 0

<— Received SIP response (415 bytes) from WSS:157.44.68.155:62289 —>
SIP/2.0 100 Trying (sent from the Transaction Layer)
Via: SIP/2.0/WSS 172.31.46.5:8089;rport=8089;branch=z9hG4bKPj55a2fe4a-7c7c-462b-9fb6-32ebc78180d7;alias
From: "Anonymous"sip:Anonymous@ip-172-31-46-5.us-west-2.compute.internal;tag=c1c9e03f-fd78-4d06-9438-cc7736d6ebcb
To: sips:sipML5@157.44.68.155;rtcweb-breaker=no
Call-ID: eb0b0146-5f27-4be1-b328-31fea36e1051
CSeq: 25135 INVITE
Content-Length: 0

<— Received SIP response (547 bytes) from WSS:157.44.68.155:62289 —>
SIP/2.0 180 Ringing
Via: SIP/2.0/WSS 172.31.46.5:8089;rport=8089;branch=z9hG4bKPj55a2fe4a-7c7c-462b-9fb6-32ebc78180d7;alias
From: "Anonymous"sip:Anonymous@ip-172-31-46-5.us-west-2.compute.internal;tag=c1c9e03f-fd78-4d06-9438-cc7736d6ebcb
To: sips:sipML5@157.44.68.155;rtcweb-breaker=no;tag=V4UOTLWQ1ZuRU7FF3GD5
Contact: sips:sipML5@df7jal23ls0d.invalid;transport=wss
Call-ID: eb0b0146-5f27-4be1-b328-31fea36e1051
CSeq: 25135 INVITE
Content-Length: 0
Allow: ACK, BYE, CANCEL, INVITE, MESSAGE, NOTIFY, OPTIONS, PRACK, REFER, UPDATE

-- PJSIP/sipML5-0000000f is ringing
-- PJSIP/sipML5-0000000f is ringing

<— Transmitting SIP response (866 bytes) to TLS:54.172.60.2:43735 —>
SIP/2.0 180 Ringing
Via: SIP/2.0/TLS 54.172.60.2:5061;rport=43735;received=54.172.60.2;branch=z9hG4bKabd9.bb1b95e6.0
Via: SIP/2.0/UDP 172.18.53.80:5060;rport=5060;received=172.18.53.80;branch=z9hG4bK48edd39a-ebd1-4f7f-952a-04c4fb843ffb_6772d868_494-8139753403888067550
Record-Route: sip:54.172.60.2:5061;transport=tls;lr;r2=on
Record-Route: sip:54.172.60.2:5060;lr;r2=on
Call-ID: 33e73869790c6d331db804894d141076@0.0.0.0
From: “Anonymous” sip:Anonymous@zemoso-trial.pstn.twilio.com;tag=79189298_6772d868_48edd39a-ebd1-4f7f-952a-04c4fb843ffb
To: sip:+16173000430@34.222.155.151;tag=94d32028-bddd-4224-be56-bf2fb4e12c59
CSeq: 25455 INVITE
Server: Asterisk PBX 15.5.0
Contact: sip:34.222.155.151:5061;transport=TLS
Allow: OPTIONS, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, REGISTER, MESSAGE, REFER
Content-Length: 0

You can control this using causecode in Hangup application. You’ll have to send the incoming call to next priority after Dial (using option g) and then use Hangup application.

I don’t think you can actually generate 603 with cause codes. Also remember that Asterisk is a back to back user agent, not a proxy.

Asterisk is an ISDN PABX with SIP bolted, on so, for a normal call, 603 gets translated internally to 21 (declined), as per RFC 3398. RFC 3398 says that that should translated back as 403 unless the cause location is “user”, but Asterisk doesn’t actually track the cause location. So, for a normal call, I’d expect to see 403.

My guess is that, because messages aren’t normally calls, there isn’t a clear mapping onto ISDN and they go through simplified processing where nearly every failure is treated the same.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.