Connect FreePBX to Twilio SIP

Hi all

Trying to setup an outbound SIP trunk using Twilio SIP.

I have my ‘Outbound Route’ setup to catch anything prefixed with a 9 (no other dial plan settings in place) and push it down my Twilio ‘Trunk’. My Trunk is setup using:-

host=xxxxxxxxx.sip.twilio.com
type=peer
qualify=no

I didn’t specify any authentication details either in my SIP settings or at the Twilio end.

When I try and dial out from a SIP connected phone I get the following in the logs…

[2015-05-07 08:54:58] VERBOSE[30277][C-00000012] pbx.c: Executing [901736xxxxxx@from-internal:1] ResetCDR(“SIP/1576-00000016”, “”) in new stack
[2015-05-07 08:54:58] VERBOSE[30277][C-00000012] pbx.c: Executing [901736xxxxxx@from-internal:2] NoCDR(“SIP/1576-00000016”, “”) in new stack
[2015-05-07 08:54:58] VERBOSE[30277][C-00000012] pbx.c: Executing [901736xxxxxx@from-internal:3] Progress(“SIP/1576-00000016”, “”) in new stack
[2015-05-07 08:54:58] VERBOSE[30277][C-00000012] pbx.c: Executing [901736xxxxxx@from-internal:4] Wait(“SIP/1576-00000016”, “1”) in new stack
[2015-05-07 08:54:59] VERBOSE[30277][C-00000012] pbx.c: Executing [901736xxxxxx@from-internal:5] Progress(“SIP/1576-00000016”, “”) in new stack
[2015-05-07 08:54:59] VERBOSE[30277][C-00000012] pbx.c: Executing [901736xxxxxx@from-internal:6] Playback(“SIP/1576-00000016”, “silence/1&cannot-complete-as-dialed&check-number-dial-again,noanswer”) in new stack
[2015-05-07 08:54:59] VERBOSE[30277][C-00000012] file.c: <SIP/1576-00000016> Playing ‘silence/1.ulaw’ (language ‘en’)
[2015-05-07 08:55:00] VERBOSE[30277][C-00000012] file.c: <SIP/1576-00000016> Playing ‘cannot-complete-as-dialed.ulaw’ (language ‘en’)
[2015-05-07 08:55:02] VERBOSE[30277][C-00000012] file.c: <SIP/1576-00000016> Playing ‘check-number-dial-again.ulaw’ (language ‘en’)
[2015-05-07 08:55:04] VERBOSE[30277][C-00000012] pbx.c: Executing [901736xxxxxx@from-internal:7] Wait(“SIP/1576-00000016”, “1”) in new stack
[2015-05-07 08:55:05] VERBOSE[30277][C-00000012] pbx.c: Executing [901736xxxxxx@from-internal:8] Congestion(“SIP/1576-00000016”, “20”) in new stack
[2015-05-07 08:55:05] WARNING[30277][C-00000012] channel.c: Prodding channel ‘SIP/1576-00000016’ failed
[2015-05-07 08:55:05] VERBOSE[30277][C-00000012] pbx.c: Spawn extension (from-internal, 901736751576, 8) exited non-zero on ‘SIP/1576-00000016’
[2015-05-07 08:55:05] VERBOSE[30277][C-00000012] pbx.c: Executing [h@from-internal:1] Hangup(“SIP/1576-00000016”, “”) in new stack
[2015-05-07 08:55:05] VERBOSE[30277][C-00000012] pbx.c: Spawn extension (from-internal, h, 1) exited non-zero on ‘SIP/1576-00000016’

Basically it looks like it’s hanging up as it can’t get dial-tone. I’ve tried various different dial-out number formats as I know Twilio likes 44 in front of the numbers… but I don’t seem to be making any progress.

At this stage I’m not even sure the SIP trunk is even connecting to Twilio.

I have found (and read) this…


…but at this stage I want to keep my SIP setup as simple as possible to just prove it works. I have tried the config listed and got the same results in case anyone reading this was wondering. :smile:

Any help would be very greatly appreciated.

Cheers

Mike

Right or wrong, not sure, but here is my setup that seems to be working…

Outgoing PEER Details
username=*****
type=peer
secret=*****
host=*****.pstn.twilio.com

Incoming PEER Details
host=54.172.60.1
type=peer
context=from-trunk

I have this sorta duplicated out to cover 54.172.60.0/2/3 as well.

Here is our Twilio PJSIP trunk configuration. It’s as simple as it gets.

“cannot-complete-as-dialed” means that the number called did not match an Outbound Route, so it didn’t even try to access the trunk.

For this test, you could try:
Prepend: +44
Prefix: 90
Match Pattern: X.
CallerID: (leave blank)

If it now accesses the trunk but you still have trouble, don’t mess around with chan_sip. Delete the trunk and set it up with pjsip as Twilio documentation shows, or as @dobrosavljevic posted.

The only thing that might not be correct for you is the Context as we use that one in the US.

Sorry, I messed up (and then edited) my previous post. Look at the edited Outbound Route settings.

Wait, this initial post is from 2015. What the crap?

You’re right; I guess we should all pay more attention.

Oh crap… sorry guys. I was searching through threads on Twilio and got this one mixed up with new current threads. On a side note, I think I’m moving to PJSIP. That setup looks super easy. Thanks @dobrosavljevic