Asterisk outbound configuration with Twilio fails

I have set up my Twilio account to receive outbound calls from my asterisk sip server.

I have made a registration request as per the docs

register => <user>:<password>@<termination_uri>.pstn.us1.twilio.com

These are the log from sip set debug on

Retransmitting #2 (no NAT) to 54.172.60.3:5060:
REGISTER sip:<termination_uri>.pstn.us1.twilio.com SIP/2.0
Via: SIP/2.0/UDP <sip_server_ip>:5060;branch=z9hG4bK4f338547
Max-Forwards: 70
From: <sip:<user>@<termination_uri>.pstn.us1.twilio.com>;tag=as655fbd71
To: <sip:<user>@<termination_uri>.pstn.us1.twilio.com>
Call-ID: 44b6bf8f0421dd862f704bdd37efb675@10.128.0.12
CSeq: 104 REGISTER
Supported: replaces, timer
User-Agent: Asterisk PBX certified/13.21-cert2
Expires: 120
Contact: <sip:s@<sip_server_ip>:5060>
Content-Length: 0

The request fails to go through even after multiple retries, sip show registry shows:

Host                                    dnsmgr Username       Refresh State                Reg.Time                
 
<termination_uri>.pstn.us1.twilio.com:5060    N      666                120 Request Sent                                 
 
1 SIP registrations.

Your log is excessive obfuscated. One cannot distinguish between public and private addresses. My suspicion is that this is a NAT issues.

I assume that your SIP server and SIP client have the same address. Asterisk is operating as a client when issuing the register, but the intent of register is to supply an address to use when it is is the initial server.

The <sip_server_ip> is the public address :slight_smile:
I just tried with a different provider nexmo and it seems to work with them? following these docs

A SIP server should respond to even invalid SIP requests. That strongly suggests that something is stopping the replay getting back to Asterisk.

You dont need to user registration string to recive inbound calls with Twilio Elastic trunk, Twilio will send the calls to a valid SIP uri, specified on the Origination Tab