Zap trunk failover does not work

I have two PSTN connected to two trunks via zap. If the first trunk is engage in a call, it doesn’t seem to failover to another trunk. Logs as per below and have masked the number I dialed.

-- Executing [1-dial@macro-trunkdial-failover-0.3:1] Dial("SIP/6001-003f0004", "Zap/g2/9XXXXXXX") in new stack

[Apr 9 18:56:42] WARNING[8052]: app_dial.c:1183 dial_exec_full: Unable to create channel of type ‘Zap’ (cause 34 - Circuit/channel congestion)
== Everyone is busy/congested at this time (1:0/1/0)
== Auto fallthrough, channel ‘SIP/6001-003f0004’ status is ‘CONGESTION’

Below is my configuration:

[globals]
trunk_1 = Zap/g1
trunk_2 = Zap/g2

[CallingRule_Local]
exten = _9XXXXXXX,1,Macro(trunkdial-failover-0.3,${trunk_2}/${EXTEN:1},${trunk_4}/${EXTEN:1},trunk_2,trunk_4)

[macro-trunkdial-failover-0.3]
exten = s,1,Set(CALLERID(name)=${CALLERID(name)})
exten = s,n,Set(CALLERID(num)=${IF($[${LEN(${CID_${CALLERID(num)}})} > 1]?${CID_${CALLERID(num)}}:)})
exten = s,n,NoOp(${CALLERID(num)})
exten = s,n,MixMonitor(/persistent/sounds/record/${STRFTIME(${EPOCH},%C%y%m%d%H%M%S)}.wav,ab)
exten = s,n,Goto(1-dial,1)
exten = 1-dial,1,Dial(${ARG1})
exten = s,n,StopMonitor()
exten = 1-dial,n,Gotoif(${LEN(${ARG2})} > 0 ?1-${DIALSTATUS},1:1-out,1)
exten = 1-CHANUNAVAIL,1,Dial(${ARG2})
exten = 1-CHANUNAVAIL,n,Hangup()
exten = 1-CONGESTION,1,Dial(${ARG2})
exten = 1-CONGESTION,n,Hangup()
exten = 1-out,1,Hangup()

Can help suggest what seems to be the problem? Thanks.

Sorry, forgot to put in the other Zap device which is actually where the line is connected.

[globals]
trunk_1 = Zap/g1
trunk_2 = Zap/g2
trunk_4 = Zap/g3

[CallingRule_Local]
exten = _9XXXXXXX,1,Macro(trunkdial-failover-0.3,${trunk_2}/${EXTEN:1},${trunk_4}/${EXTEN:1},trunk_2,trunk_4)

[macro-trunkdial-failover-0.3]
exten = s,1,Set(CALLERID(name)=${CALLERID(name)})
exten = s,n,Set(CALLERID(num)=${IF($[${LEN(${CID_${CALLERID(num)}})} > 1]?${CID_${CALLERID(num)}}:)})
exten = s,n,NoOp(${CALLERID(num)})
exten = s,n,MixMonitor(/persistent/sounds/record/${STRFTIME(${EPOCH},%C%y%m%d%H%M%S)}.wav,ab)
exten = s,n,Goto(1-dial,1)
exten = 1-dial,1,Dial(${ARG1})
exten = s,n,StopMonitor()
exten = 1-dial,n,Gotoif(${LEN(${ARG2})} > 0 ?1-${DIALSTATUS},1:1-out,1)
exten = 1-CHANUNAVAIL,1,Dial(${ARG2})
exten = 1-CHANUNAVAIL,n,Hangup()
exten = 1-CONGESTION,1,Dial(${ARG2})
exten = 1-CONGESTION,n,Hangup()
exten = 1-out,1,Hangup()

There is no priority 2 for 1-dial and there are two priority 2’s for s. n is relative to the previous line, not to the previous line with exactly the same extension pattern.

Also, any system using zaptel is obsolete and no longer supported, and the correct syntax for extensions.conf uses “=>”, not “=”.

Finally, this is not a forum for asking support questions. Strangely the ones with “support” in their name are for doing that!

I managed to make this work by adding another Dial({$ARG2}) in the context and removing my MixMonitor. If I put in my Mixmonitor, it won’t work. Can you please help to advice how to make the failover and mix monitor work. I have tried mixing around the mix monitor line and dial but couldn’t make it work.

Can you help advice where I should put the mix monitor on the below if the two trunks will be used up and still get the recording of both calls?

[macro-trunkdial-failover-0.3]
exten = s,1,Set(CALLERID(name)=${CALLERID(name)})
exten = s,n,Set(CALLERID(num)=${IF($[${LEN(${CID_${CALLERID(num)}})} > 1]?${CID_${CALLERID(num)}}:)})
exten = s,n,NoOp(${CALLERID(num)})
exten = s,n,Goto(1-dial,1)
exten = 1-dial,1,Dial(${ARG1})
exten = 1-dial,1,Dial(${ARG2})
exten = s,n,StopMonitor()
exten = 1-dial,n,Gotoif(${LEN(${ARG2})} > 0 ?1-${DIALSTATUS},1:1-out,1)
exten = 1-CHANUNAVAIL,1,Dial(${ARG2})
exten = 1-CHANUNAVAIL,n,Hangup()
exten = 1-CONGESTION,1,Dial(${ARG2})
exten = 1-CONGESTION,n,Hangup()
exten = 1-out,1,Hangup()

Thanks.