2
votes

I have been struggling now for days with setting up Asterisk and Twilio to work with Elastic SIP Trunk. When I dial the connected Twilio number i get a busy tone. It seem to be correctly configured in the SIP Elastic Trunk on Twilio, so the issue is probably somewhere in my config files. I'm not very used to Asterisk. From the debug feature in Asterisk I can read the following relevant information:

No matching peer for '+46XXXXXXXX' from '54.171.XXX.XXX:5060'

And

<--- Reliably Transmitting (NAT) to 54.171.XX.XX:5060 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 54.171.XX.XX:5060;branch=z9hG4bK8cf9.d4ef7004.0;received=54.171.XX.XX;rport=5060
Via: SIP/2.0/UDP 172.18.XX.XX:5060;branch=z9hG4bKb51529eb-4720-40ba-b51e-bfcb6427f9e9_6772d868_3027116677418488
From: <sip:[email protected]>;tag=76483885_6772d868_b51529eb-4720-40ba-b51e-bfcb6427f9e9
To: <sip:[email protected];user=phone>;tag=as63d15d89
Call-ID: [email protected]
CSeq: 102 INVITE
Server: Asterisk PBX 11.7.0~dfsg-1ubuntu1
Allow: INVITE, ACK, CANCEL, OPTIONS, BYE, REFER, SUBSCRIBE, NOTIFY, INFO, PUBLISH
Supported: replaces
WWW-Authenticate: Digest algorithm=MD5, realm="asterisk", nonce="552df87e"
Content-Length: 0

My relevant configuration is

sip.conf

[twilio]
type=peer
host=XXXX.pstn.twilio.com
context=incoming
fromdomain=XXXX.pstn.twilio.com
fromuser=+46XXXXXXXX ;My twilio number
dtmfmode=rfc2833
canreinvite=yes
qualify=no
disallow=all
allow=ulaw
insecure=port,invite
allowguest=yes
nat=yes

extensions.conf

[incoming]
exten => s,1,Answer()
exten => s,n,Dial(SIP/100&SIP/7001&SIP/7004, 60)
exten => s,n,Playback(vm-nobodyavail)
exten => s,n,VoiceMail(100@main)
exten => s,n,Hangup()

I guess it has something to do with the Unauthorized error, however I have set up Twilio to accept my server IP and tho not authorize with username and password. To mention is that it works for my outbound routing. The issue is probably not related to internal routing as it works to call between my extensions. Also, all of my clients are behind NAT but the server is not behind NAT.

What is wrong with my config? Does anyone have a working example with twilio and asterisk?

1
Twilio site HAVE working example for asterisk. In your case seams like you have double nat. So you have deal acordinly.arheops
@arheops Thanks, the Twilio example did not work for me though, not even on a clean install of Asterisk. Though the issue has been resolved now. I created two peer interfaces, one for dialing out and one for incoming calls.rctl

1 Answers

-4
votes

Forget "SIP Trunking" configuration. These calls you´re receiving from "SIPOut API servers", that´s the reason for the "No matching peer". sip.conf needs another type of peer to handle with SIPOut calls. Google it.