Asterisk Fallover for Calls

Hi All,

So I am now on such a place where im fairly okay-ish with asterisk and how it works.

With that said, I am trying to figure out how to auto forward calls to another asterisk box, before anyone says its easy, let me explain the setup, I obviously cant give real system names or real service provider names or real IP’s so i will do it in a way that should theoretically make sense to most.

Vital Server: This is where all the calls are sent from within the company and this system then splits it to service providers on a load balancing manor + cost effective routing and per IAXVAR for hard coded CLI’s

Service Providers Interconnect: This is 3 Service providers Asterisk Box, Lets Name them SP1. SP2, SP3

Now currently if say SP1 gets a fibre sip failure we manually have to turn off all calls to that SP with the Vital server.

The idea is to make something as follows.

Vitals → SP1 if SP1 is down auto send it to SP2 and if SP2 is down send to SP3
Vitals → SP2 if SP2 is down auto send it to SP3 and if SP3 is down send to SP1
Vitals → SP3 if SP3 is down auto send it to SP1 and if SP1 is down send to SP2

So this means i need to figure out in extensions.conf if it sends it to the Service provider and the service provider gives an error back or anything like that, Not a no answer or hangup or like that just the SIP is down or Call Failed then it needs to redirect that call to SP2.

So the part i use as an example below is in the 1 SP extensions.conf. IP’s removed obviously.

[macro-threecli2]

exten => s,1,GotoIfTime(00:01-11:30,,,?first)
exten => s,2,GotoIfTime(11:30-23:59,
,,?second)

exten => s,n(first),Set(DATEONE=${STRFTIME(${EPOCH},Africa/Cairo,%Y%m%d)}1)
exten => s,n,GoTo(getnum)
exten => s,n(second),Set(DATEONE=${STRFTIME(${EPOCH},Africa/Cairo,%Y%m%d)}2)
exten => s,n,GoTo(getnum)

exten => s,n(getnum),Set(CELNUMONE=${DB(List/${DATEONE})})
exten => s,n,Set(CALLERID(number)=27${CELNUMONE:1}) ; To remove the 0 and add 27 infront of the number
exten => s,n,Set(CALLERID(name)==27${CELNUMONE:1}) ; To remove the 0 and add 27 infront of the number
exten => s,n,SIPAddHeader(P-Asserted-Identity:Private sip:Private@SPsbc)
exten => s,n,Dial(SIP/${ARG1}@SPsbc1)
exten => s,n,NoOp( Dial Status: ${DIALSTATUS})
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n,Hangup()

So now what would i have to add where in this above to forward the call to another SP box if the Dial fails for any reason?

Hope to hear from anyone here. And yes i know i am still using SIP and not PJSip

Forgot to also mention, I am not sure exactly how to check in extensions.conf after or even before dial if the SIP channel is active or not to the Service provider. If a person can check that then you can even bounce the call before it is even dialled.

DEVICE_STATE can tell you whether the endpoint is in use. However, unless you are using a service intended for phones, rather than PABXes, in use will not mean you can’t add another call.

I never understand why people feel the need to redact the provider. It an be important information with little security impact.

Ok So the Service Providers are Vodacom, MTN, Neotel. South African Service providers. and yes we do about 2000 calls per second on the lines. but like now, Neotel has a massive Fibre break somewhere or network failure and then its manually move all calls from there and move it to the other 2.

and thanks. I will look into that DEVICE_STATE, ill see what it does and what it should do and if it will work on our setup.

Just an update, The code i more or less got to work is as follows.

exten => s,n,Set(sip_status=${DEVICE_STATE(SIP/liquid)})
exten => s,n,NoOp(SIP Status: ${sip_status})
exten => s,n,GotoIf($[${sip_status} = UNAVAILABLE]?handle_unreachable)
exten => s,n,GotoIf($[${sip_status} = UNREACHABLE]?handle_unreachable)
exten => s,n,GotoIf($[${sip_status} = UNKNOWN]?handle_unreachable)
exten => s,n,Dial(SIP/${ARG1}@liquid)
exten => s,n,NoOp( Dial Status: ${DIALSTATUS})
exten => s,n,Goto(s-${DIALSTATUS},1)
exten => s,n,Hangup()
exten => s,n(handle_unreachable),Dial(IAX2/liquidfail/${ARG1})
exten => s,n,Hangup()

This seems to do the trick when the sip is not working. Probably not idea and i know for a fact that there is someone somewhere which has a better way of doing this.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.