Iax-pstn failover


I have 2 asterisks boxes A,B linked via IAX2. I am tyring to do Least Cost Routing from A to B vias B PSTN network.

So if I make a call from A, it gets routed via the IAX2 trunk to B in that B will try to use its PSTN line.

All works well, however for what ever reason B’s PSTN line is BUSY, UNAVAILABLE etc I now need to fallback onto A’s PSTN line.

However the DIALSTATUS routine does not seem to be workign on As machine as it never gets to operation 4, see code below.

I think I somehow need to get the DIALSTATUS of B’s PSTN to A’s DIALPLAN. How would one do this?

exten => _XXXXXXXXXX,1,Macro(authorize_outbound,locals.pin)
exten => _XXXXXXXXXX,2,Macro(record)
exten => _XXXXXXXXXX,3,Dial(${IAX2/RHODES}/${EXTEN},60,tT)
exten => _XXXXXXXXXX,6,Dial(${ZAP/G0/${EXTEN},60,tT)
exten => _XXXXXXXXXX,7,Macro(outisbusy)
exten => _XXXXXXXXXX,8,Hangup()

any help please

The above line doesn’t look right to me unless you had it truncated here without a “)”. OTOH, the logic behind is doesn’t sound right to me, too because regardless the condition is the branch always goes to “6” (the next line).


the systax was truncated, if the IF clause fails it should go to line 7

in any case the problem is since the call has been established via the IAX2 protocal, systems B is now handling the Dialplan not System A, therefore System A will not get any dialstatus.

Thats my observation. I could be totaly wrong here,


Have you thought of useing RetryDial?

Place a call, retrying on failure allowing optional exit extension.

Place a call, retrying on failure allowing optional exit extension.

RetryDial(announce|sleep|retries|dialargs): This application will attempt to
place a call using the normal Dial application. If no channel can be reached,
the ‘announce’ file will be played. Then, it will wait ‘sleep’ number of
seconds before retying the call. After ‘retires’ number of attempts, the
calling channel will continue at the next priority in the dialplan. If the
’retries’ setting is set to 0, this application will retry endlessly.
While waiting to retry a call, a 1 digit extension may be dialed. If that
extension exists in either the context defined in ${EXITCONTEXT} or the current
one, The call will jump to that extension immediately.
The ‘dialargs’ are specified in the same format that arguments are provided
to the Dial application.