Asterisk Dial Failover


#1

All,

I have an Asterisk system that sends PSTN calls to an OpenSER system to be routed. I have a command like this in my extensions.conf:

exten => 1_.,1,Dial(SIP/${EXTEN}@proxy,20,tr)

There’s actually two OpenSER systems for redundancy. I’m trying to find a way to have Asterisk attempt to route the call to one OpenSER system, and if it’s down, fallback to another.

Any first thoughts on how to achieve this?

I can’t have Asterisk do a DNS SRV lookup because Asterisks SRV lookups are broken. If I issue a series of Dial commands, such as this:

exten => 1_.,1,Dial(SIP/${EXTEN}@proxy1,20,tr)
exten => 1_.,2,Dial(SIP/${EXTEN}@proxy2,20,tr)

… what seems to happen is that when proxy1 is down, Asterisk waits the full 20 seconds before returning control. Also, This 20s includes the time is takes for the other end to answer, so if I put a small value of say 5s in there, the dial command will probably give up before someone answers at the other end. Neither is workable.

Asterisk SHOULD be able to distinguish between a TRYING and no response. In the event it gets no TRYING response to a dial command within a specified timeout it should return control and flag an error. If on the other hand it does get a TRYING response (and maybe a RINGING too) it should continue to wait until the 20s has expired.

I can’t use dynamic DNS (ie putting two A records for a hostname in DNS) because Asterisk reads the extensions.conf on startup and also seems to cache what the host maps to on startup. Subsequent calls to the host always return the same IP address.

But… in general… how have people implemented this?

Help appreciated!
Doug


#2

Does Asterisk register with the proxy? You could also try something like:

exten => 1_.,1,Dial(SIP/${EXTEN}@proxy1&SIP/${EXTEN}@proxy2,20,tr)


#3

No, it doesn’t register with the proxy. There’s no point.

If Asterisk did register it would register as say, ‘asterisk@domain’. SER could only route to asterisk if the call was specifically for a user called ‘asterisk@domain’.

I could try dialling all the proxies at once though… altho I don’t like that approach. If we add another proxy and have three, chances are there will be two proxies dialling our PSTN gateway. Actually even with only two proxies, if both are up, we’ll be dialling twice. I’m sure this isn’t a good thing.


#4

Why do the 20 seconds?

If you are only trying to do a failover, get rid of the ,20.

This should work fine for you:

exten => 1_.,1,Dial(SIP/${EXTEN}@proxy1)
exten => 1_.,2,Dial(SIP/${EXTEN}@proxy2)

If the first is busy, then it will try #2 immediately.


#5

I guest that you use the proxy1 in usual situation,other proxy be backup proxy ,once proxy1 broken,other backup proxys can work ,the user may not realize the difference.If is so,maybe a way below could solve the problem.
step1:
make sure proxy1 and proxy2 can place the same call,that is Proxy2 can really BACKUP the proxy1’s calls.

step2:
modify the extensions.conf such as:

exten => 1_.,1,Dial(SIP/${EXTEN}@proxy1&Local(90${EXTEN})@backup,20,tr)
[backup]
exten => _90.,1,wait(15)
exten => _90.,2,Dial(${EXTEN:2}@proxy2,20,tr)
the most important is that the Local channels must be valid.

Thus,when user dial a number such as 10000,the extension place the number to proxy1 and local channel at the same time, But local channels won’t place the call immediately ,It will wait 15 second.
Now if proxy1 can work now,the dial application wouldn’t continue the call of Local channel,so call is successful,But if proxy1 is broken now,never mind ,after 15 second, the local channel willl place the call to proxy2.Be more attension to the
[color=red] exten => _90.,2,Dial(${EXTEN:2}@proxy2,20,tr)[/color]
It can be pointed out easilly that 90 is only a special char for identify.

Wish It can solve your problem. Thanks