Same issue as yours

Continuing the discussion from Trunk context problems:

Hey Majren, I am having the same issue as yours, i have created an Inbound route for a SIP trunk, and the calls are not getting connected. Will you be able to tell me how you fixed your issue ? Please

I had a firewall that was blocking my connection.

Complete Description of the issue :-

Incoming calls through a SIP trunk is not taking the correct context and taking “from-internal” context automatically, even if it is set up for “from-trunk” context.

FreePBX :

Setup :-

2723(extension on CUCM) - (SIP Trunk) - FreePBX

Config of SIP Trunk :-
Peer Details :-

User Details :-

Inbound Route :-
DID Number = 9000
Destination : Extension 2723 (This is an extension in FreePBX)

Here in the user-details for the sip trunk, the context for all the incoming calls is set to “from-trunk”, but when any incoming call is made, it uses “from-internal” only and does not use “from-trunk” at all. Because of this :-

  1. We are able to call the extensions in FreePBX directly without any Inbound Routes.
    Log1 is attached for this call, where the extension 2723 in CUCM is able to call Extension 2723, without any inbound Route config, since it uses “from-internal” context.
  2. We are NOT able to call anything configured in the Inbound Routes. Since the INBOUND route uses “from-trunk” context
    The Inbound Route has a DID : 9000, which in turn calls the extension 2723 in FreePBX. But since the number 9000 is searched in the “from-internal” context, it never works.
    Log2 is attached for this call, where the extension 2723 in CUCM is trying to call 9000 in FreePBX, 9000 is a DID for an Inbound Route, it uses “from-internal” again as the context and gets a fast busy. The error message 503 Service Unavailable is sent to the CUCM. The FreePBX should have used “from-trunk” to search for the DID 9000. If it had done that, it would have followed the dial-plan below
    Below is the output : dialplan show [email protected]
    [ Included context ‘ext-did-0002’ created by ‘pbx_config’ ]
    ‘9000’ => 1. Set(__FROM_DID=$
    {EXTEN}) [pbx_config]
  3. Gosub(sub-record-check,s,1(in,${EXTEN}
    ,dontcare)) [pbx_config]
  4. Gosub(app-blacklist-check,s,1()) [pbx_config]
  5. Set(CDR(did)=$
    ) [pbx_config]
  6. ExecIf($[ “$
    ” = “” ] ?Set(CALLERID(name)=$
    )) [pbx_config]
  7. Set(CHANNEL(musicclass)=default) [pbx_config]
  8. Set(__MOHCLASS=default) [pbx_config]
  9. GotoIf($["${__REVERSAL_REJECT}"=“TRUE” & “$
    ”=“1” ]?macro-hangupcall) [pbx_config]
  10. Set(__CALLINGPRES_SV=$
    ) [pbx_config]
  11. Set(CALLERPRES()=allowed_not_screened) [pbx_config]
    [dest-ext] 11. Goto(from-did-direct,2723,1) [pbx_config]
    [ Included context ‘ext-did-catchall’ created by ‘pbx_config’ ]
    ’.’ => 1. Set(_FROM_DID=$
    {EXTEN}) [pbx_config]
  12. Noop(Received an unknown call with DID set to ${EXTEN}
    ) [pbx_config]
  13. Goto(s,a2) [pbx_config]
    = 2 extensions (14 priorities) in 2 contexts. =

Solution/Workaround :-

  1. The CUCM cannot have a SIP trunk which needs registration and nor can it authenticate when challenged.
  2. So the trunk between CUCM and the Asterisk has no Secret set, and it has “allow Anonymous calls” on.
  3. According to the developers in FreePBX, if it is configured in such a way, the FreePBX will consider the SIP trunk to be internal and search for the call flow in “from-internal” context, even though it has been set to use “from-external”.

User Details :-

  1. This seems to be a buggy behaviour but as per FreePBX it is working as per design.
  2. The Above calls were not working, since the DIDs in Inbound Routes are in “from-external” context.
  3. Whereas when a call comes from the SIP trunk, it tries to search the context “from-internal”,

Here are the Trace snippets :-

[2015-09-21 04:23:01] VERBOSE[11160][C-0000001c] chan_sip.c: Looking for 2723 in from-internal (domain

Hope this helps someone.

Thank You,