When running a call-center setup where you strive to be 100% available at all times, it is important not to assume that your PBX, Internet links or even VoIP carrier will be 100% reliable.

In this post, we will try to explain why it’s important to have multiple SIP peers and to use a secondary SIP peer properly.

When configuring Asterisk, it is possible to activate a feature for each SIP peer called “qualify“. This feature acts as a keep-alive mechanism (SIP OPTIONS) and makes sure your peer is always up and responds in the expected manner – ping measurement. When your sip peer is not responding or its ping latency is too high, Asterisk will mark the peer as LAGGED and will act as a failed response (DIALSTATUS=CHANUNAVAIL).

So your SIP peer should look something like this:

; sip.conf entry
; CommPeak Tokyo POP
[commpeak-jp]
type=peer
host=tokyo.sip.commpeak.com
qualify=130 ; Our average ping is 85ms
username=123
password=456
disallow=all
allow=g729
allow=ulaw
context=commpeak

So what happens now is, if tokyo.sip.commpeak.com will have ping latency higher than 130ms or no reply it all, Asterisk won’t bother using it and therefore there won’t be any delays when initiating Dial() calls to it. This will make sure that both your SIP peer is alive and is in proper shape, and it won’t cause any unplanned delays in your dial-plan execution in case something goes wrong. Now we’ll want to have a fail-over SIP peer, so let’s write our secondary SIP peer:

; sip.conf entry
; CommPeak Singapore POP
[commpeak-sg]
type=peer
host=singapore.sip.commpeak.com
qualify=150 ; Our average ping is 100ms
username=123
password=456
disallow=all
allow=g729
allow=ulaw
context=commpeak

People normally do the following in order to have a fail-over:

exten => _X.,1,Noop("Sending calls through CommPeak")
exten => _X.,n,Dial(SIP/commpeak-jp/${EXTEN}
exten => _X.,n,Dial(SIP/commpeak-sg/${EXTEN}

The problem with this approach is that if the number to which you dialed is simply BUSY or any other status not related to the health of your SIP peer, then this would still engage a second call through the second peer.

A more proper way to do this would be to read the DIALSTATUS code and only engage with the second peer if DIALSTATUS=CHANUNAVAIL, please see the multiple examples in VoIP-Info as there are multiple ways of doing this, based on your dialplan (either by using Macro, GotoIf or AEL2 logic).

Want to learn more? Here are some relevant references:

Want to find out more about CommPeak’s tech capabilities? Stop by CommPeak.com and read more about our powerful wholesale VoIP services.