Unable to route outbound calls with Custom Contexts

I am trying to setup Trixbox so that certain user extensions only go out certain trunks. I have installed the custom contexts module and appear to have it working from watching the log. The problem is when I specify a context to only allow a specific trunk (g4 in this case) I get a busy signal. When I allow the g0 trunk, it will route out the first trunk, second trunk, etc by whichever is available and work just fine.

It may also be worth mentioning that I have setup Zap Channel DIDs and Inbound routes so that if a specific trunk gets a call it is forwarded to a specific extension. This part of it works fine and the same trunk will route to the extension fine.

I am running Trixbox 2.6.2.3
The trunk card is a Sangoma A200 with 4FXO ports. The module and util version are the most current that is listed on Sangoma’s website for this version of Trixbox. (3.5.4.8-0)

Below is a snippet of code from the CLI when I try to make a call using the custom context. I have changed the number being dialed to 217-555-1212 as I don’t want my phone number plastered all over the Internet. I have tried this with more than one number so I am not suspecting a problem with the phone company. Please let me know if there is anything that is needed.

 -- Executing [912175551212@rachel-outbound:1] Macro("SIP/2920-089923e0", "user-callerid|SKIPTTL|") in new stack
    -- Executing [s@macro-user-callerid:1] Set("SIP/2920-089923e0", "AMPUSER=2920") in new stack
    -- Executing [s@macro-user-callerid:2] GotoIf("SIP/2920-089923e0", "0?report") in new stack
    -- Executing [s@macro-user-callerid:3] ExecIf("SIP/2920-089923e0", "1|Set|REALCALLERIDNUM=2920") in new stack
    -- Executing [s@macro-user-callerid:4] Set("SIP/2920-089923e0", "AMPUSER=2920") in new stack
    -- Executing [s@macro-user-callerid:5] Set("SIP/2920-089923e0", "AMPUSERCIDNAME=Todd") in new stack
    -- Executing [s@macro-user-callerid:6] GotoIf("SIP/2920-089923e0", "0?report") in new stack
    -- Executing [s@macro-user-callerid:7] Set("SIP/2920-089923e0", "AMPUSERCID=2920") in new stack
    -- Executing [s@macro-user-callerid:8] Set("SIP/2920-089923e0", "CALLERID(all)="Todd" <2920>") in new stack
    -- Executing [s@macro-user-callerid:9] Set("SIP/2920-089923e0", "REALCALLERIDNUM=2920") in new stack
    -- Executing [s@macro-user-callerid:10] ExecIf("SIP/2920-089923e0", "0|Set|CHANNEL(language)=") in new stack
    -- Executing [s@macro-user-callerid:11] GotoIf("SIP/2920-089923e0", "1?continue") in new stack
    -- Goto (macro-user-callerid,s,20)
    -- Executing [s@macro-user-callerid:20] NoOp("SIP/2920-089923e0", "Using CallerID "Todd" <2920>") in new stack
    -- Executing [912175551212@rachel-outbound:2] Set("SIP/2920-089923e0", "_NODEST=") in new stack
    -- Executing [912175551212@rachel-outbound:3] Macro("SIP/2920-089923e0", "record-enable|2920|OUT|") in new stack
    -- Executing [s@macro-record-enable:1] GotoIf("SIP/2920-089923e0", "1?check") in new stack
    -- Goto (macro-record-enable,s,4)
    -- Executing [s@macro-record-enable:4] AGI("SIP/2920-089923e0", "recordingcheck|20100222-135857|1266868737.79") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/recordingcheck
  recordingcheck|20100222-135857|1266868737.79: Outbound recording not enabled
    -- AGI Script recordingcheck completed, returning 0
    -- Executing [s@macro-record-enable:5] MacroExit("SIP/2920-089923e0", "") in new stack
    -- Executing [912175551212@rachel-outbound:4] Macro("SIP/2920-089923e0", "dialout-trunk|6|12175551212||") in new stack
    -- Executing [s@macro-dialout-trunk:1] Set("SIP/2920-089923e0", "DIAL_TRUNK=6") in new stack
    -- Executing [s@macro-dialout-trunk:2] GosubIf("SIP/2920-089923e0", "0?sub-pincheck|s|1") in new stack
    -- Executing [s@macro-dialout-trunk:3] GotoIf("SIP/2920-089923e0", "0?disabletrunk|1") in new stack
    -- Executing [s@macro-dialout-trunk:4] Set("SIP/2920-089923e0", "DIAL_NUMBER=12175551212") in new stack
    -- Executing [s@macro-dialout-trunk:5] Set("SIP/2920-089923e0", "DIAL_TRUNK_OPTIONS=tr") in new stack
    -- Executing [s@macro-dialout-trunk:6] Set("SIP/2920-089923e0", "OUTBOUND_GROUP=OUT_6") in new stack
    -- Executing [s@macro-dialout-trunk:7] GotoIf("SIP/2920-089923e0", "1?nomax") in new stack
    -- Goto (macro-dialout-trunk,s,9)
    -- Executing [s@macro-dialout-trunk:9] GotoIf("SIP/2920-089923e0", "0?skipoutcid") in new stack
    -- Executing [s@macro-dialout-trunk:10] Set("SIP/2920-089923e0", "DIAL_TRUNK_OPTIONS=") in new stack
    -- Executing [s@macro-dialout-trunk:11] Macro("SIP/2920-089923e0", "outbound-callerid|6") in new stack
    -- Executing [s@macro-outbound-callerid:1] ExecIf("SIP/2920-089923e0", "0|SetCallerPres|") in new stack
    -- Executing [s@macro-outbound-callerid:2] ExecIf("SIP/2920-089923e0", "0|Set|REALCALLERIDNUM=2920") in new stack
    -- Executing [s@macro-outbound-callerid:3] GotoIf("SIP/2920-089923e0", "1?normcid") in new stack
    -- Goto (macro-outbound-callerid,s,6)
    -- Executing [s@macro-outbound-callerid:6] Set("SIP/2920-089923e0", "USEROUTCID=") in new stack
    -- Executing [s@macro-outbound-callerid:7] Set("SIP/2920-089923e0", "EMERGENCYCID=") in new stack
    -- Executing [s@macro-outbound-callerid:8] Set("SIP/2920-089923e0", "TRUNKOUTCID=") in new stack
    -- Executing [s@macro-outbound-callerid:9] GotoIf("SIP/2920-089923e0", "1?trunkcid") in new stack
    -- Goto (macro-outbound-callerid,s,12)
    -- Executing [s@macro-outbound-callerid:12] ExecIf("SIP/2920-089923e0", "0|Set|CALLERID(all)=") in new stack
    -- Executing [s@macro-outbound-callerid:13] ExecIf("SIP/2920-089923e0", "0|Set|CALLERID(all)=") in new stack
    -- Executing [s@macro-outbound-callerid:14] ExecIf("SIP/2920-089923e0", "0|SetCallerPres|prohib_passed_screen") in new stack
    -- Executing [s@macro-dialout-trunk:12] ExecIf("SIP/2920-089923e0", "0|AGI|fixlocalprefix") in new stack
    -- Executing [s@macro-dialout-trunk:13] Set("SIP/2920-089923e0", "OUTNUM=12175551212") in new stack
    -- Executing [s@macro-dialout-trunk:14] Set("SIP/2920-089923e0", "custom=ZAP/g4") in new stack
    -- Executing [s@macro-dialout-trunk:15] ExecIf("SIP/2920-089923e0", "0|Set|DIAL_TRUNK_OPTIONS=M(setmusic^)") in new stack
    -- Executing [s@macro-dialout-trunk:16] Macro("SIP/2920-089923e0", "dialout-trunk-predial-hook|") in new stack
    -- Executing [s@macro-dialout-trunk-predial-hook:1] MacroExit("SIP/2920-089923e0", "") in new stack
    -- Executing [s@macro-dialout-trunk:17] GotoIf("SIP/2920-089923e0", "0?bypass|1") in new stack
    -- Executing [s@macro-dialout-trunk:18] GotoIf("SIP/2920-089923e0", "0?customtrunk") in new stack
    -- Executing [s@macro-dialout-trunk:19] Dial("SIP/2920-089923e0", "ZAP/g4/12175551212|300|") in new stack
  == Everyone is busy/congested at this time (1:0/0/1)
    -- Executing [s@macro-dialout-trunk:20] Goto("SIP/2920-089923e0", "s-CHANUNAVAIL|1") in new stack
    -- Goto (macro-dialout-trunk,s-CHANUNAVAIL,1)
    -- Executing [s-CHANUNAVAIL@macro-dialout-trunk:1] GotoIf("SIP/2920-089923e0", "1?noreport") in new stack
    -- Goto (macro-dialout-trunk,s-CHANUNAVAIL,3)
    -- Executing [s-CHANUNAVAIL@macro-dialout-trunk:3] NoOp("SIP/2920-089923e0", "TRUNK Dial failed due to CHANUNAVAIL (hangupcause: 0) - failing through to other trunks") in new stack
    -- Executing [912175551212@rachel-outbound:5] Macro("SIP/2920-089923e0", "outisbusy|") in new stack
    -- Executing [s@macro-outisbusy:1] Playback("SIP/2920-089923e0", "all-circuits-busy-now|noanswer") in new stack
    -- <SIP/2920-089923e0> Playing 'all-circuits-busy-now' (language 'en')
    -- Executing [s@macro-outisbusy:2] Playback("SIP/2920-089923e0", "pls-try-call-later|noanswer") in new stack
    -- <SIP/2920-089923e0> Playing 'pls-try-call-later' (language 'en')
    -- Executing [s@macro-outisbusy:3] Macro("SIP/2920-089923e0", "hangupcall") in new stack
    -- Executing [s@macro-hangupcall:1] ResetCDR("SIP/2920-089923e0", "vw") in new stack
    -- Executing [s@macro-hangupcall:2] NoCDR("SIP/2920-089923e0", "") in new stack
    -- Executing [s@macro-hangupcall:3] GotoIf("SIP/2920-089923e0", "1?skiprg") in new stack
    -- Goto (macro-hangupcall,s,6)
    -- Executing [s@macro-hangupcall:6] GotoIf("SIP/2920-089923e0", "1?skipblkvm") in new stack
    -- Goto (macro-hangupcall,s,9)
    -- Executing [s@macro-hangupcall:9] GotoIf("SIP/2920-089923e0", "1?theend") in new stack
    -- Goto (macro-hangupcall,s,11)
    -- Executing [s@macro-hangupcall:11] Hangup("SIP/2920-089923e0", "") in new stack
  == Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'SIP/2920-089923e0' in macro 'hangupcall'
  == Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'SIP/2920-089923e0' in macro 'outisbusy'
  == Spawn extension (macro-hangupcall, s, 11) exited non-zero on 'SIP/2920-089923e0'

Thanks,
Todd

I don’t think this is related to custom-contexts. Asterisk is clearly trying to send the call over zap/g4 and failing. Are there any FXOs in Zap trunk group g4 and are those trunks connected and working?

The response your are getting is that no trunks are available. The dial plan has worked correctly for context “rachel-outbound”. Is there a group-4 or are you trying to send it to just zap/4 rather than zap/g4? Check you trunk group and be sure of what you have set up.

Thanks kenn10. I took the g out and left it as just the number (ie. zap/4) and it started working, but this brought up a new problem.

I am trying to get one of the contexts to use two lines: one primary and one failover. The idea is if someone calls in on line 1 and I want to put that person on hold and dial out, I would like to failover my outbound call to line 2. When I set the custom context to allow both line 1 and 2, proceed to busy out line 1 (the primary,) the system will not failover to line 2 on making an outbound call (it repeats the above, it never tries the second line).

I have tried setting the priority’s in the custom context to 49 for the first line and 50 for the second line, and setting them both to the same priority, but both lead me to the same result.

You need two outbound routes and two trunk groups. Put zap/1 (or whichever zap it is) in the first trunk group and put zap/2 (or whichever zap it is) in the second trunk group.

Create two routes named something like “Outbound-A” and “Outbound-B”.
In Outbound-A have trunk group 1 and then trunk group 2.
In Outbound-B have trunk group 2 and then trunk group 1.

In your custom contexts, have one context allow Outbound-A and deny Outbound-B. In the other custom context, have the context allow Outbound-B and deny Outbound-A. Remember to deny “Outbound All Routes” and deny “Entire Basic Dial Plan” in either custom context.

Hopefully, this makes sense to you. The lack of documentation on the Custom-Contexts module tends to leave people confused in what needs to be done to set things up.