Twilio Inbound route calles get “the number you have dialed is not in service”

I am kind of new to the PBX and the free PBX world. I successfully installed and configure my freepbx server. it is up and running I can call ext to ext and was able to successfully create an outbound route trough twilio elastic sip however my inbound rout is not working

I created a inbound route and I am getting the error “the number you have dialed is not in service” I have configure the route for both a ring group and to ring the extension directly and the result is the same. not sure what I am doing wrong.

Any help will be appreciated

Need logs…
https://wiki.freepbx.org/pages/viewpage.action?pageId=30245283#ProvidingGreatDebug-AsteriskLogs

Here are the logs the call I tried

[2017-10-07 11:10:57] VERBOSE[105567][C-00000070] pbx.c:     -- Executing [+16023627646@from-sip-external:2] Set("SIP/arielcucm.pstn.twilio.com-000000be", "DID=+16023627646") in new stack
[2017-10-07 11:10:57] VERBOSE[105567][C-00000070] pbx.c:     -- Executing [+16023627646@from-sip-external:3] Goto("SIP/arielcucm.pstn.twilio.com-000000be", "s,1") in new stack
[2017-10-07 11:10:57] VERBOSE[105567][C-00000070] pbx.c:     -- Goto (from-sip-external,s,1)
[2017-10-07 11:10:57] VERBOSE[105567][C-00000070] pbx.c:     -- Executing [s@from-sip-external:1] GotoIf("SIP/arielcucm.pstn.twilio.com-000000be", "1?setlanguage:checkanon") in new stack
[2017-10-07 11:10:57] VERBOSE[105567][C-00000070] pbx.c:     -- Goto (from-sip-external,s,2)
[2017-10-07 11:10:57] VERBOSE[105567][C-00000070] pbx.c:     -- Executing [s@from-sip-external:2] Set("SIP/arielcucm.pstn.twilio.com-000000be", "CHANNEL(language)=en") in new stack
[2017-10-07 11:10:57] VERBOSE[105567][C-00000070] pbx.c:     -- Executing [s@from-sip-external:3] GotoIf("SIP/arielcucm.pstn.twilio.com-000000be", "1?noanonymous") in new stack
[2017-10-07 11:10:57] VERBOSE[105567][C-00000070] pbx.c:     -- Goto (from-sip-external,s,5)
[2017-10-07 11:10:57] VERBOSE[105567][C-00000070] pbx.c:     -- Executing [s@from-sip-external:5] Set("SIP/arielcucm.pstn.twilio.com-000000be", "TIMEOUT(absolute)=15") in new stack
[2017-10-07 11:10:57] VERBOSE[105567][C-00000070] func_timeout.c:     -- Channel will hangup at 2017-10-07 11:11:12.649 MST.
[2017-10-07 11:10:57] VERBOSE[105567][C-00000070] pbx.c:     -- Executing [s@from-sip-external:6] Log("SIP/arielcucm.pstn.twilio.com-000000be", "WARNING,"Rejecting unknown SIP connection from 54.172.60.1"") in new stack
[2017-10-07 11:10:57] WARNING[105567][C-00000070] Ext. s: "Rejecting unknown SIP connection from 54.172.60.1"
[2017-10-07 11:10:57] VERBOSE[105567][C-00000070] pbx.c:     -- Executing [s@from-sip-external:7] Answer("SIP/arielcucm.pstn.twilio.com-000000be", "") in new stack
[2017-10-07 11:10:58] VERBOSE[105567][C-00000070] pbx.c:     -- Executing [s@from-sip-external:8] Wait("SIP/arielcucm.pstn.twilio.com-000000be", "2") in new stack
[2017-10-07 11:11:00] VERBOSE[105567][C-00000070] pbx.c:     -- Executing [s@from-sip-external:9] Playback("SIP/arielcucm.pstn.twilio.com-000000be", "ss-noservice") in new stack
[2017-10-07 11:11:00] VERBOSE[105567][C-00000070] file.c:     -- <SIP/arielcucm.pstn.twilio.com-000000be> Playing 'ss-noservice.ulaw' (language 'en')
[2017-10-07 11:11:05] VERBOSE[105567][C-00000070] pbx.c:     -- Executing [s@from-sip-external:10] PlayTones("SIP/arielcucm.pstn.twilio.com-000000be", "congestion") in new stack
[2017-10-07 11:11:05] VERBOSE[105567][C-00000070] pbx.c:     -- Executing [s@from-sip-external:11] Congestion("SIP/arielcucm.pstn.twilio.com-000000be", "5") in new stack
[2017-10-07 11:11:10] VERBOSE[105567][C-00000070] pbx.c:   == Spawn extension (from-sip-external, s, 11) exited non-zero on 'SIP/arielcucm.pstn.twilio.com-000000be'
[2017-10-07 11:11:10] VERBOSE[105567][C-00000070] pbx.c:     -- Executing [h@from-sip-external:1] Hangup("SIP/arielcucm.pstn.twilio.com-000000be", "") in new stack
[2017-10-07 11:11:10] VERBOSE[105567][C-00000070] pbx.c:   == Spawn extension (from-sip-external, h, 1) exited non-zero on 'SIP/arielcucm.pstn.twilio.com-000000be'
[2017-10-07 11:11:29] WARNING[1953] chan_sip.c: Retransmission timeout reached on transmission [email protected] for seqno 413406 (Critical Response)

y goal is to try to place a call and forward it to ext 1000 which is an ext on my cucm currently I can dial from asterisk to cucm exts. and from cuum to asterisk ext. my outdial from cucm to the pstn is also not working I get the same error ext not available please try again and here are the logs for a call from cucm to the pstn trough asterisk.

[2017-10-07 11:22:15] VERBOSE[1953][C-00000071] netsock2.c:   == Using SIP RTP TOS bits 184
[2017-10-07 11:22:15] VERBOSE[1953][C-00000071] netsock2.c:   == Using SIP RTP CoS mark 5
[2017-10-07 11:22:15] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [4808623802@from-trunk-sip-Trunk to cucm:1] Set("SIP/Trunk to cucm-000000bf", "GROUP()=OUT_3") in new stack
[2017-10-07 11:22:15] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [4808623802@from-trunk-sip-Trunk to cucm:2] Goto("SIP/Trunk to cucm-000000bf", "from-trunk,4808623802,1") in new stack
[2017-10-07 11:22:15] VERBOSE[106574][C-00000071] pbx.c:     -- Goto (from-trunk,4808623802,1)
[2017-10-07 11:22:15] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [4808623802@from-trunk:1] Set("SIP/Trunk to cucm-000000bf", "__FROM_DID=4808623802") in new stack
[2017-10-07 11:22:15] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [4808623802@from-trunk:2] NoOp("SIP/Trunk to cucm-000000bf", "Received an unknown call with DID set to 4808623802") in new stack
[2017-10-07 11:22:15] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [4808623802@from-trunk:3] Goto("SIP/Trunk to cucm-000000bf", "s,a2") in new stack
[2017-10-07 11:22:15] VERBOSE[106574][C-00000071] pbx.c:     -- Goto (from-trunk,s,2)
[2017-10-07 11:22:15] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [s@from-trunk:2] Answer("SIP/Trunk to cucm-000000bf", "") in new stack
[2017-10-07 11:22:15] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [s@from-trunk:3] Log("SIP/Trunk to cucm-000000bf", "WARNING,Friendly Scanner from 192.168.0.10") in new stack
[2017-10-07 11:22:15] WARNING[106574][C-00000071] Ext. s: Friendly Scanner from 192.168.0.10
[2017-10-07 11:22:15] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [s@from-trunk:4] Wait("SIP/Trunk to cucm-000000bf", "2") in new stack
[2017-10-07 11:22:17] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [s@from-trunk:5] Playback("SIP/Trunk to cucm-000000bf", "ss-noservice") in new stack
[2017-10-07 11:22:17] VERBOSE[106574][C-00000071] file.c:     -- <SIP/Trunk to cucm-000000bf> Playing 'ss-noservice.ulaw' (language 'en')
[2017-10-07 11:22:22] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [s@from-trunk:6] SayAlpha("SIP/Trunk to cucm-000000bf", "4808623802") in new stack
[2017-10-07 11:22:22] VERBOSE[106574][C-00000071] file.c:     -- <SIP/Trunk to cucm-000000bf> Playing 'digits/4.ulaw' (language 'en')
[2017-10-07 11:22:22] VERBOSE[106574][C-00000071] file.c:     -- <SIP/Trunk to cucm-000000bf> Playing 'digits/8.ulaw' (language 'en')
[2017-10-07 11:22:23] VERBOSE[106574][C-00000071] file.c:     -- <SIP/Trunk to cucm-000000bf> Playing 'digits/0.ulaw' (language 'en')
[2017-10-07 11:22:24] VERBOSE[106574][C-00000071] file.c:     -- <SIP/Trunk to cucm-000000bf> Playing 'digits/8.ulaw' (language 'en')
[2017-10-07 11:22:24] VERBOSE[106574][C-00000071] file.c:     -- <SIP/Trunk to cucm-000000bf> Playing 'digits/6.ulaw' (language 'en')
[2017-10-07 11:22:25] VERBOSE[106574][C-00000071] file.c:     -- <SIP/Trunk to cucm-000000bf> Playing 'digits/2.ulaw' (language 'en')
[2017-10-07 11:22:26] VERBOSE[106574][C-00000071] file.c:     -- <SIP/Trunk to cucm-000000bf> Playing 'digits/3.ulaw' (language 'en')
[2017-10-07 11:22:26] VERBOSE[106574][C-00000071] file.c:     -- <SIP/Trunk to cucm-000000bf> Playing 'digits/8.ulaw' (language 'en')
[2017-10-07 11:22:27] VERBOSE[106574][C-00000071] file.c:     -- <SIP/Trunk to cucm-000000bf> Playing 'digits/0.ulaw' (language 'en')
[2017-10-07 11:22:28] VERBOSE[106574][C-00000071] file.c:     -- <SIP/Trunk to cucm-000000bf> Playing 'digits/2.ulaw' (language 'en')
[2017-10-07 11:22:28] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [s@from-trunk:7] Hangup("SIP/Trunk to cucm-000000bf", "") in new stack
[2017-10-07 11:22:28] VERBOSE[106574][C-00000071] pbx.c:   == Spawn extension (from-trunk, s, 7) exited non-zero on 'SIP/Trunk to cucm-000000bf'
[2017-10-07 11:22:28] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [h@from-trunk:1] Macro("SIP/Trunk to cucm-000000bf", "hangupcall,") in new stack
[2017-10-07 11:22:28] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [s@macro-hangupcall:1] ExecIf("SIP/Trunk to cucm-000000bf", "0?Set(CDR(recordingfile)=.)") in new stack
[2017-10-07 11:22:28] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [s@macro-hangupcall:2] GotoIf("SIP/Trunk to cucm-000000bf", "1?theend") in new stack
[2017-10-07 11:22:28] VERBOSE[106574][C-00000071] pbx.c:     -- Goto (macro-hangupcall,s,4)
[2017-10-07 11:22:28] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [s@macro-hangupcall:4] ExecIf("SIP/Trunk to cucm-000000bf", "0?Set(CDR(recordingfile)=)") in new stack
[2017-10-07 11:22:28] VERBOSE[106574][C-00000071] pbx.c:     -- Executing [s@macro-hangupcall:5] Hangup("SIP/Trunk to cucm-000000bf", "") in new stack
[2017-10-07 11:22:28] VERBOSE[106574][C-00000071] app_macro.c:   == Spawn extension (macro-hangupcall, s, 5) exited non-zero on 'SIP/Trunk to cucm-000000bf' in macro 'hangupcall'
[2017-10-07 11:22:28] VERBOSE[106574][C-00000071] pbx.c:   == Spawn extension (from-trunk, h, 1) exited non-zero on 'SIP/Trunk to cucm-000000bf'

Not sure if I should make a separate post for this one

Inbound call is being treated as anonymous, as evidenced by the the from-sip-external context. This is usually a trunk misconfig, the inbound call arrives from an unexpected host.

[2017-10-07 11:10:57] VERBOSE[105567][C-00000070] pbx.c:     -- Executing [+16023627646@from-sip-external:2] Set("SIP/arielcucm.pstn.twilio.com-000000be", "DID=+16023627646") in new stack

How do I fix this, do I change the configuration on astrsik to accept anonymous sip

I got it working now I can make and receive call from asterisk. Now I have an ext on cucm 1000 how can I forward all incoming calls to that ext. also when I try to call from cucm an outbound number it is ringing the ext that I have enable for the in bound route in cucm. I can I forward the call to the pstn

Guys, it is Twilio. They deliver inbound calls from up to FIVE different IPs. You need your trunks to match all those IPs. In the case of Chan_SIP you need a Chan_SIP trunk for each IP. If you are using Chan_PJSIP, you can add them in the Match list.

It is as simple as that. Their documents are pretty clear about how to do this.

I was able to figure this one out also " I am now able to call in to the asterisk PBX" and forward the call to a cucm ext I used the misc destinations. the only thing left is able to place an outbound call from cucm trough Free PBX is that possible.

I have yet another questions . In bound and aoutbound calls from twilio are working. I am able to forward an external call to cucm and dial exts in between both systems. how ever when an external call comes in it drops after 32 seconds. Any ideas

Turn on SIP debugging and you will see. Call drop at 30 seconds is because the ACK request is not being received. In the SIP dialog setup (simplified) the caller sends INVITE, the recipient accepts the call and replies with 200 OK, then the caller sends ACK to finish the sequence.

were do I enable sip debug, and what do I do to correct this

Google “asterisk sip debug” and how to correct the problem depends on what you find out from the debugs…

I enable debug mode. I have not been able to get a log because my server is not accessible right now and is on a remote location. but I did had twilio look at a log snippet I sent them and this is what they told me:

Twilio is sending the initial INVITE to 184.98.217.155 however it is sending the ACK to a 184.98.160.208 address, and it appears your equipment is not getting the ACK, as it is resending the 200 OK, until it eventually times out and disconnects the call after 32 seconds.

The reason we are sending the ACK to a 184.98.160.208 is due to the fact that this is the address which is in the Contact header returned in the 200 OK from your equipment (184.98.217.155). I am thinking that .155 never sees the ACK and times out the call (sends a BYE) after 32 seconds.

So to rectify there are 2 options:

(a) Have .155 insert itself into a Record-Route header in the 200 OK
(b) Figure out why .208 is being inserted into the contact header rather than .155

My question is why will it be seeing 2 ip address. It is a simple dsl modem with dhcp address

Check the external IP configured in Asterisk SIP Settings.