Skip to content

Instantly share code, notes, and snippets.

@mymindstorm
Created June 27, 2020 18:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mymindstorm/c5b8095a38624364960f9e313b644476 to your computer and use it in GitHub Desktop.
Save mymindstorm/c5b8095a38624364960f9e313b644476 to your computer and use it in GitHub Desktop.
Asterisk issue
; Test extension
[from-internal]
exten = 100,1,Answer()
same = n,Wait(1)
same = n,Playback(hello-world)
same = n,Wait(20)
same = n,Hangup()
; Internal extensions
[from-internal]
exten => _6XXX,1,Dial(PJSIP/${EXTEN},20)
; Internal extension hints
[from-internal]
exten = 6001,hint,PJSIP/6001
exten = 6002,hint,PJSIP/6002
; PSTN routing
[from-internal]
exten => _NXXNXXXXXX,1,Set(CALLERID(all)="Caller ID" <+1<trunk phone number>>)
same => n,Dial(PJSIP/+1${EXTEN}@twilio-na-us)
same => n(end),Hangup()
[from-pstn]
exten=> _+1NXXXXXXXXX,1,Dial(PJSIP/6001)
192.168.1.50 is Asterisk
192.168.1.79 is IP Phone (Cisco 7941)
<--- Received SIP request (1379 bytes) from UDP:192.168.1.76:49788 --->
INVITE sip:<dialed pstn number>@192.168.1.50;user=phone SIP/2.0
Via: SIP/2.0/UDP 192.168.1.76:5060;branch=z9hG4bKcd16b922
From: "6001" <sip:6001@192.168.1.50>;tag=0022905b11f600776e1ed23c-3b60bcbd
To: <sip:<dialed pstn number>@192.168.1.50>
Call-ID: 0022905b-11f60028-86b987a2-49db0edf@192.168.1.76
Max-Forwards: 70
Date: Sat, 27 Jun 2020 18:17:27 GMT
CSeq: 101 INVITE
User-Agent: Cisco-CP7941G/9.3.1
Contact: <sip:6001@192.168.1.76:5060;user=phone;transport=udp>
Expires: 180
Accept: application/sdp
Allow: ACK,BYE,CANCEL,INVITE,NOTIFY,OPTIONS,REFER,REGISTER,UPDATE,SUBSCRIBE,INFO
Remote-Party-ID: "6001" <sip:6001@192.168.1.50>;party=calling;id-type=subscriber;privacy=off;screen=yes
Supported: replaces,join,sdp-anat,norefersub,resource-priority,extended-refer,X-cisco-callinfo,X-cisco-serviceuri,X-cisco-escapecodes,X-cisco-service-control,X-cisco-srtp-fallback,X-cisco-monrec,X-cisco-config,X-cisco-sis-6.0.0,X-cisco-xsi-8.5.1
Allow-Events: dialog
Content-Length: 328
Content-Type: application/sdp
Content-Disposition: session;handling=optional
v=0
o=Cisco-SIPUA 10839 0 IN IP4 192.168.1.76
s=SIP Call
t=0 0
m=audio 17046 RTP/AVP 0 8 18 102 9 101
c=IN IP4 192.168.1.76
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:102 L16/16000
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
<--- Transmitting SIP response (512 bytes) to UDP:192.168.1.76:5060 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.1.76:5060;received=192.168.1.76;branch=z9hG4bKcd16b922
Call-ID: 0022905b-11f60028-86b987a2-49db0edf@192.168.1.76
From: "6001" <sip:6001@192.168.1.50>;tag=0022905b11f600776e1ed23c-3b60bcbd
To: <sip:<dialed pstn number>@192.168.1.50>;tag=z9hG4bKcd16b922
CSeq: 101 INVITE
WWW-Authenticate: --snip--
Server: Asterisk PBX 17.4.0
Content-Length: 0
<--- Received SIP request (392 bytes) from UDP:192.168.1.76:49918 --->
ACK sip:<dialed pstn number>@192.168.1.50;user=phone SIP/2.0
Via: SIP/2.0/UDP 192.168.1.76:5060;branch=z9hG4bKcd16b922
From: "6001" <sip:6001@192.168.1.50>;tag=0022905b11f600776e1ed23c-3b60bcbd
To: <sip:<dialed pstn number>@192.168.1.50>;tag=z9hG4bKcd16b922
Call-ID: 0022905b-11f60028-86b987a2-49db0edf@192.168.1.76
Max-Forwards: 70
Date: Sat, 27 Jun 2020 18:17:27 GMT
CSeq: 101 ACK
Content-Length: 0
<--- Received SIP request (1655 bytes) from UDP:192.168.1.76:49788 --->
INVITE sip:<dialed pstn number>@192.168.1.50;user=phone SIP/2.0
Via: SIP/2.0/UDP 192.168.1.76:5060;branch=z9hG4bKc2dff840
From: "6001" <sip:6001@192.168.1.50>;tag=0022905b11f600776e1ed23c-3b60bcbd
To: <sip:<dialed pstn number>@192.168.1.50>
Call-ID: 0022905b-11f60028-86b987a2-49db0edf@192.168.1.76
Max-Forwards: 70
Date: Sat, 27 Jun 2020 18:17:27 GMT
CSeq: 102 INVITE
User-Agent: Cisco-CP7941G/9.3.1
Contact: <sip:6001@192.168.1.76:5060;user=phone;transport=udp>
Authorization: Digest username="6001",realm="asterisk",uri="sip:<dialed pstn number>@192.168.1.50;user=phone",--snip--
Expires: 180
Accept: application/sdp
Allow: ACK,BYE,CANCEL,INVITE,NOTIFY,OPTIONS,REFER,REGISTER,UPDATE,SUBSCRIBE,INFO
Remote-Party-ID: "6001" <sip:6001@192.168.1.50>;party=calling;id-type=subscriber;privacy=off;screen=yes
Supported: replaces,join,sdp-anat,norefersub,resource-priority,extended-refer,X-cisco-callinfo,X-cisco-serviceuri,X-cisco-escapecodes,X-cisco-service-control,X-cisco-srtp-fallback,X-cisco-monrec,X-cisco-config,X-cisco-sis-6.0.0,X-cisco-xsi-8.5.1
Allow-Events: dialog
Content-Length: 328
Content-Type: application/sdp
Content-Disposition: session;handling=optional
v=0
o=Cisco-SIPUA 10839 0 IN IP4 192.168.1.76
s=SIP Call
t=0 0
m=audio 17046 RTP/AVP 0 8 18 102 9 101
c=IN IP4 192.168.1.76
a=rtpmap:0 PCMU/8000
a=rtpmap:8 PCMA/8000
a=rtpmap:18 G729/8000
a=fmtp:18 annexb=no
a=rtpmap:102 L16/16000
a=rtpmap:9 G722/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-15
a=sendrecv
== Setting global variable 'SIPDOMAIN' to '192.168.1.50'
<--- Transmitting SIP response (340 bytes) to UDP:192.168.1.76:5060 --->
SIP/2.0 100 Trying
Via: SIP/2.0/UDP 192.168.1.76:5060;received=192.168.1.76;branch=z9hG4bKc2dff840
Call-ID: 0022905b-11f60028-86b987a2-49db0edf@192.168.1.76
From: "6001" <sip:6001@192.168.1.50>;tag=0022905b11f600776e1ed23c-3b60bcbd
To: <sip:<dialed pstn number>@192.168.1.50>
CSeq: 102 INVITE
Server: Asterisk PBX 17.4.0
Content-Length: 0
-- Executing [<dialed pstn number>@from-internal:1] Set("PJSIP/6001-0000000a", "CALLERID(all)="Caller ID" <+1<trunk phone number>>") in new stack
-- Executing [<dialed pstn number>@from-internal:2] Dial("PJSIP/6001-0000000a", "PJSIP/+1<dialed pstn number>@twilio-na-us") in new stack
-- Called PJSIP/+1<dialed pstn number>@twilio-na-us
<--- Transmitting SIP request (1052 bytes) to TLS:54.244.51.1:5061 --->
INVITE sip:+1<dialed pstn number>@xxx.pstn.us2.twilio.com:5061 SIP/2.0
Via: SIP/2.0/TLS 192.168.1.50:5061;rport;branch=z9hG4bKPj533a7fad-34f5-42f3-93f0-fdc85664bcac;alias
From: "Caller ID" <sip:+1<trunk phone number>@127.0.0.2>;tag=fdc3a875-f57c-417a-92db-e5ffebd2311a
To: <sip:+1<dialed pstn number>@xxx.pstn.us2.twilio.com>
Contact: <sip:asterisk@192.168.1.50:5061;transport=TLS>
Call-ID: dd22b39f-09a7-4ac3-a00c-69d67e11af14
CSeq: 2163 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 17.4.0
Content-Type: application/sdp
Content-Length: 308
v=0
o=- 673363588 673363588 IN IP4 (null)
s=Asterisk
c=IN IP4 (null)
t=0 0
m=audio 14566 RTP/SAVP 0 101
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:muZ7HIxhWrXKhdmIOkyxqQeUkce7XNoYp6+02SW9
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
<--- Received SIP response (416 bytes) from TLS:54.244.51.1:5061 --->
SIP/2.0 100 Giving a try
Via: SIP/2.0/TLS 192.168.1.50:5061;received=<my public ip>;rport=56551;branch=z9hG4bKPj533a7fad-34f5-42f3-93f0-fdc85664bcac;alias
From: "Caller ID" <sip:+1<trunk phone number>@127.0.0.2>;tag=fdc3a875-f57c-417a-92db-e5ffebd2311a
To: <sip:+1<dialed pstn number>@xxx.pstn.us2.twilio.com>
Call-ID: dd22b39f-09a7-4ac3-a00c-69d67e11af14
CSeq: 2163 INVITE
Server: Twilio Gateway
Content-Length: 0
<--- Received SIP response (680 bytes) from TLS:54.244.51.1:5061 --->
SIP/2.0 407 Proxy Authentication required
CSeq: 2163 INVITE
Call-ID: dd22b39f-09a7-4ac3-a00c-69d67e11af14
From: "Caller ID" <sip:+1<trunk phone number>@127.0.0.2>;tag=fdc3a875-f57c-417a-92db-e5ffebd2311a
To: <sip:+1<dialed pstn number>@xxx.pstn.us2.twilio.com>;tag=98657391_6772d868_ee995842-94d6-484f-9650-313757118b1c
Via: SIP/2.0/TLS 192.168.1.50:5061;received=<my public ip>;rport=56551;branch=z9hG4bKPj533a7fad-34f5-42f3-93f0-fdc85664bcac;alias
Server: Twilio
Contact: <sip:172.18.69.152:5060>
Proxy-Authenticate: --snip--
Content-Length: 0
<--- Transmitting SIP request (512 bytes) to TLS:54.244.51.1:5061 --->
ACK sip:+1<dialed pstn number>@xxx.pstn.us2.twilio.com:5061 SIP/2.0
Via: SIP/2.0/TLS 192.168.1.50:5061;rport;branch=z9hG4bKPj533a7fad-34f5-42f3-93f0-fdc85664bcac;alias
From: "Caller ID" <sip:+1<trunk phone number>@127.0.0.2>;tag=fdc3a875-f57c-417a-92db-e5ffebd2311a
To: <sip:+1<dialed pstn number>@xxx.pstn.us2.twilio.com>;tag=98657391_6772d868_ee995842-94d6-484f-9650-313757118b1c
Call-ID: dd22b39f-09a7-4ac3-a00c-69d67e11af14
CSeq: 2163 ACK
Max-Forwards: 70
User-Agent: Asterisk PBX 17.4.0
Content-Length: 0
<--- Transmitting SIP request (1401 bytes) to TLS:54.244.51.1:5061 --->
INVITE sip:+1<dialed pstn number>@xxx.pstn.us2.twilio.com:5061 SIP/2.0
Via: SIP/2.0/TLS 192.168.1.50:5061;rport;branch=z9hG4bKPj17dc9a0f-93b4-489b-a012-c1367f7aa650;alias
From: "Caller ID" <sip:+1<trunk phone number>@127.0.0.2>;tag=fdc3a875-f57c-417a-92db-e5ffebd2311a
To: <sip:+1<dialed pstn number>@xxx.pstn.us2.twilio.com>
Contact: <sip:asterisk@192.168.1.50:5061;transport=TLS>
Call-ID: dd22b39f-09a7-4ac3-a00c-69d67e11af14
CSeq: 2164 INVITE
Allow: OPTIONS, REGISTER, SUBSCRIBE, NOTIFY, PUBLISH, INVITE, ACK, BYE, CANCEL, UPDATE, PRACK, MESSAGE, REFER
Supported: 100rel, timer, replaces, norefersub
Session-Expires: 1800
Min-SE: 90
Max-Forwards: 70
User-Agent: Asterisk PBX 17.4.0
Proxy-Authorization: --snip--
Content-Type: application/sdp
Content-Length: 308
v=0
o=- 673363588 673363588 IN IP4 (null)
s=Asterisk
c=IN IP4 (null)
t=0 0
m=audio 14566 RTP/SAVP 0 101
a=crypto:1 AES_CM_128_HMAC_SHA1_80 inline:muZ7HIxhWrXKhdmIOkyxqQeUkce7XNoYp6+02SW9
a=rtpmap:0 PCMU/8000
a=rtpmap:101 telephone-event/8000
a=fmtp:101 0-16
a=ptime:20
a=maxptime:150
a=sendrecv
<--- Received SIP response (416 bytes) from TLS:54.244.51.1:5061 --->
SIP/2.0 100 Giving a try
Via: SIP/2.0/TLS 192.168.1.50:5061;received=<my public ip>;rport=56551;branch=z9hG4bKPj17dc9a0f-93b4-489b-a012-c1367f7aa650;alias
From: "Caller ID" <sip:+1<trunk phone number>@127.0.0.2>;tag=fdc3a875-f57c-417a-92db-e5ffebd2311a
To: <sip:+1<dialed pstn number>@xxx.pstn.us2.twilio.com>
Call-ID: dd22b39f-09a7-4ac3-a00c-69d67e11af14
CSeq: 2164 INVITE
Server: Twilio Gateway
Content-Length: 0
<--- Received SIP response (554 bytes) from TLS:54.244.51.1:5061 --->
SIP/2.0 400 Bad SDP
CSeq: 2164 INVITE
Call-ID: dd22b39f-09a7-4ac3-a00c-69d67e11af14
From: "Caller ID" <sip:+1<trunk phone number>@127.0.0.2>;tag=fdc3a875-f57c-417a-92db-e5ffebd2311a
To: <sip:+1<dialed pstn number>@xxx.pstn.us2.twilio.com>;tag=73911467_6772d868_3fed89a1-e5f2-4c64-a79f-7aa9e47f04d9
Via: SIP/2.0/TLS 192.168.1.50:5061;received=<my public ip>;rport=56551;branch=z9hG4bKPj17dc9a0f-93b4-489b-a012-c1367f7aa650;alias
Server: Twilio
Contact: <sip:172.18.82.9:5060>
X-Twilio-Error: 32102 The SDP is not correctly formatted.
Content-Length: 0
<--- Transmitting SIP request (512 bytes) to TLS:54.244.51.1:5061 --->
ACK sip:+1<dialed pstn number>@xxx.pstn.us2.twilio.com:5061 SIP/2.0
Via: SIP/2.0/TLS 192.168.1.50:5061;rport;branch=z9hG4bKPj17dc9a0f-93b4-489b-a012-c1367f7aa650;alias
From: "Caller ID" <sip:+1<trunk phone number>@127.0.0.2>;tag=fdc3a875-f57c-417a-92db-e5ffebd2311a
To: <sip:+1<dialed pstn number>@xxx.pstn.us2.twilio.com>;tag=73911467_6772d868_3fed89a1-e5f2-4c64-a79f-7aa9e47f04d9
Call-ID: dd22b39f-09a7-4ac3-a00c-69d67e11af14
CSeq: 2164 ACK
Max-Forwards: 70
User-Agent: Asterisk PBX 17.4.0
Content-Length: 0
== Everyone is busy/congested at this time (1:0/0/1)
-- Executing [<dialed pstn number>@from-internal:3] Hangup("PJSIP/6001-0000000a", "") in new stack
== Spawn extension (from-internal, <dialed pstn number>, 3) exited non-zero on 'PJSIP/6001-0000000a'
<--- Transmitting SIP response (421 bytes) to UDP:192.168.1.76:5060 --->
SIP/2.0 500 Internal Server Error
Via: SIP/2.0/UDP 192.168.1.76:5060;received=192.168.1.76;branch=z9hG4bKc2dff840
Call-ID: 0022905b-11f60028-86b987a2-49db0edf@192.168.1.76
From: "6001" <sip:6001@192.168.1.50>;tag=0022905b11f600776e1ed23c-3b60bcbd
To: <sip:<dialed pstn number>@192.168.1.50>;tag=b6c4151b-3306-4532-9f24-809a7acbfc66
CSeq: 102 INVITE
Server: Asterisk PBX 17.4.0
Reason: Q.850;cause=127
Content-Length: 0
<--- Received SIP request (413 bytes) from UDP:192.168.1.76:49749 --->
ACK sip:<dialed pstn number>@192.168.1.50;user=phone SIP/2.0
Via: SIP/2.0/UDP 192.168.1.76:5060;branch=z9hG4bKc2dff840
From: "6001" <sip:6001@192.168.1.50>;tag=0022905b11f600776e1ed23c-3b60bcbd
To: <sip:<dialed pstn number>@192.168.1.50>;tag=b6c4151b-3306-4532-9f24-809a7acbfc66
Call-ID: 0022905b-11f60028-86b987a2-49db0edf@192.168.1.76
Max-Forwards: 70
Date: Sat, 27 Jun 2020 18:17:27 GMT
CSeq: 102 ACK
Content-Length: 0
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0
allow_reload=no
local_net=192.168.1.0/24
external_media_address=xxx.duckdns.org
external_signaling_address=xxx.duckdns.org
[transport-tls]
type=transport
protocol=tls
bind=0.0.0.0:5061
local_net=192.168.1.0/24
external_media_address=xxx.duckdns.org
external_signaling_address=xxx.duckdns.org
cert_file=/etc/asterisk/keys/asterisk.pem
priv_key_file=/etc/asterisk/keys/asterisk.key
method=tlsv1
allow_reload=no
tos=cs3
cos=3
[6001]
type=endpoint
force_rport=no
context=from-internal
disallow=all
allow=ulaw
auth=6001
aors=6001
acl=internal-only
[6001]
type=auth
auth_type=userpass
password=--snip--
username=6001
[6001]
type=aor
max_contacts=1
remove_existing=true
[6002]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
auth=6002
aors=6002
acl=internal-only
[6002]
type=auth
auth_type=userpass
password=--snip--
username=6002
[6002]
type=aor
max_contacts=1
[trunk_defaults](!)
type = wizard
endpoint/transport = transport-tls
endpoint/media_encryption = sdes
endpoint/allow = !all,ulaw
endpoint/t38_udptl=no
endpoint/t38_udptl_ec=none
endpoint/fax_detect=no
endpoint/trust_id_inbound=no
endpoint/t38_udptl_nat=no
endpoint/direct_media=no
endpoint/rewrite_contact=yes
endpoint/rtp_symmetric=yes
endpoint/dtmf_mode=rfc4733
endpoint/allow_subscribe = no
[twilio-na-us](trunk_defaults)
sends_auth = yes
sends_registrations = no
remote_hosts = xxx.pstn.us1.twilio.com:5061,xxx.pstn.us2.twilio.com:5061
outbound_auth/username = xxx
outbound_auth/password = --snip--
endpoint/context = from-pstn
aor/qualify_frequency = 60
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment