QUESTION Twilio Setup

thefuzz4

Member
Joined
Apr 30, 2011
Messages
67
Reaction score
2
So I've followed all of the instructions I can find with setting up Twilio in the Incredible PBX

I'm on Current Asterisk Version: 13.22.0/Incredible PBX 13.0.192.19

I can get outbound to work just fine on Twilio but inbound for the life of me I cannot figure out.

I've whitelisted the IPs on my Firewall and setup NAT to forward them to the server. I can see in the Firewall Logs that its forwarding the packets on down the line. But when I place a test call using the Twilio test call button nothing shows up in the logs and Twilio tells me that the connection timed out. Which I would totally understand if I was blocking it at the Firewall level. For now I've disabled IPTables on the VM as well. I have allow annonymous set to no like it should be. I will admit that Twilio uses an interesting method for inbound compared to the other SIP providers I've used in the past that normally utilize a registration string. I am just at a loss now as to what else I could be missing that would be blocking the calls coming into the PBX.

EDIT: Not sure if relevant but my Firewall is PFSense and I am on the latest and greatest.
I've also done a TCP Dump on the VM running FreePBX and I cannot see any traffic from Twilio on the VM so now this is telling me that the packets are not making it to the VM even though the Firewall says that they are being forwarded. The joys of troubleshooting :)
 
Last edited:

jreming

New Member
Joined
Mar 27, 2019
Messages
26
Reaction score
5
Do you have twilio sending to the correct address?

How do you have your trunk setup?

If using PJSIP - have twilio send to
my.pbx.com:5061
or
(not recommended)
i.p.ad.dr.ess:5061

If using SIP
same as above but with :5060

make sure you whitelisted the correct ips as well.

## broad firewall unblock, but these ips can be considered as safe but if you want to you can just allow port 5060,5061, 10000-20000 with udp

# North America - Virginia server
iptables -A INPUT -s 54.172.60.0/23 -j ACCEPT
iptables -A INPUT -s 34.203.250.0/23 -j ACCEPT
#North America - Oregon server
iptables -A INPUT -s 54.244.51.0/24 -j ACCEPT
 
  • Like
Reactions: xxolloxx

jreming

New Member
Joined
Mar 27, 2019
Messages
26
Reaction score
5
ere is how my config is setup (2+ years so far)

2x PJSip trunks

  • [Twilio-US1-North-America-Virginia]
    • [General]
      • All default
    • [pjsip Settings]
      • [General]
        • Username - set
        • Secret - set
        • Authentication - Outbound
        • Registration - None
        • SIP Server - trunkname.pstn.us1.twilio.com (may be fliped for you, 1 will always be the closest server to your location, 2 will always be the other)
        • SIP Server Port - 5060
        • Context - from-pstn-e164-us (gets rid of that funky +1)
      • [Advanced]
        • DTMF Mode - RFC 4733
      • [Codecs[
        • ulaw - only 1 checked


Save and then clone it, rename it to Twilio-US2-North-America-Oregon

and Just change the SIP Server to trunkname.pstn.us2.twilio.com

Also in Twilio for the ACL,

You should set at least an IP Access List, or Username/Password

You Origination SIP URI should be set to

sip: mypbx.server:5061

I recommend using a fqdn instead of an ip all because of failover, or future proofing.

It is much easier to edit a dns entry or use a load balancer, then set a static ip that you may have to change in the future.
 
Last edited:
  • Like
Reactions: xxolloxx

thefuzz4

Member
Joined
Apr 30, 2011
Messages
67
Reaction score
2
Thank you Jeremy I didn't know to put the port on the Twilio side as all documentation doesn't specify it. Even though I could see it coming through on 5060 on the firewall. I don't get it but recreating my trunks to use the PJSIP because I know its the new kid on the block who will probably hang out for a while. Thank you very much for your help.
 

jreming

New Member
Joined
Mar 27, 2019
Messages
26
Reaction score
5
No problem,

Also dont forget to append the + to all dial patterns in the outbound route
 
  • Like
Reactions: xxolloxx

PBX Novice

Member
Joined
Oct 24, 2018
Messages
44
Reaction score
2
I had similar frustration setting up Twilio
After messing around and setting the origination to sip:address:5061 it worked!
 
  • Like
Reactions: thefuzz4

thefuzz4

Member
Joined
Apr 30, 2011
Messages
67
Reaction score
2
Yeah would be nice if their documentation stated that. I added the + in the trunk settings under the outbound prefix stuff.
 

Members online

PIAF 5 - Powered by 3CX

Forum statistics

Threads
22,319
Messages
137,010
Members
14,549
Latest member
mawa1213