[Users] Best practice for DNS failover using OpenSER?

Christian Schlatter cs at unc.edu
Thu Jan 11 17:36:00 CET 2007


Kerker Staffan wrote:
> Now, if I disable one of the Gateways, I hang every second call. OpenSER does not
> try the second A record address if the first doesn't answer. How can I solve
> this? Shouldn't OpenSER fail over to the second A record listed in the NAPTR => SRV
> resolving? Or will OpenSER continue to resend all SIP INVITES until timers fire? Would
> it help if the proxy recieved an ICMP port/destination unreachable from the network? Is
> there anyway to get around this? In the other direction, from POTS to sip, the PGW2200
> nicely switches over to the second of my two OpenSER servers if I shut one of them down. 
> These servers have the same DNS entries (but for another SIP domain, NAPTR => SRV => 2x A record).

Yes, OpenSER or for that matter every transaction stateful proxy should 
do RFC 3263 based fail-over. But as you can imagine this is pretty 
complex to implement and that's why openser does not support it yet, it 
is listed on the development roadmap. The newest release of SER does 
support DNS failover.

But it is possible to implement failover with OpenSER, you just have to 
configure it manually on the proxy. And you have to adjust the SIP 
session timers of the tm module to achieve fast failovers.

Here is an overview of how I implemented failover with OpenSER (there 
are other ways to do that):

I use the dispatcher module with a non-random dispatcher algorithm to 
get deterministic failover.

dispatcher config file could look like:

1 sip:gw-1.example.com
1 sip:gw-2.example.com

In the openser config file, I call the ds_select_domain() function just 
before t_relay. And in the failure_route I then use ds_next_domain() to 
select the next target from the dispatcher config file.

In order to get short failover times one has to adjust fr_timer for 
INVITE transactions. For INVITE transactions, fr_timer is the max time 
openser waits for a reply from the downstream SIP entity. As soon as 
openser receives such a reply, it will use fr_inv_timer as the final 
response timer. Per default fr_timer is 30 seconds so openser would wait 
about 30 seconds before trying the next target.

An openser config that does failover between gw-1.example.com and 
gw-2.example.com for gw.example could look like:

modparam("tm", "fr_timer_avp", "i:24") # AVP to set fr_timer

# failover support --> store dests in avp value
modparam("dispatcher", "flags", 2)

route[0] {
   if (is_method("INVITE") && uri=~"sip:.*@gw.example.com") {

     # replace domain part with first dispatcher target of group 1
     ds_select_domain("1", "9"); # alg 9 --> use first, second, etc

     # set fr_timer to 3 seconds (3 seconds for failover)
     avp_write("i:3", "$avp(fr_timer)");


failure_route[1] {
   # status is 408 if openser session timer fires
   if (t_check_status("408")) {
     # replace domain part with next dispatcher target
     if (ds_next_domain()) {

- Christian

> I would love some best practice implementation clues regarding OpenSER and multiple
> GW fail over, if anyone of you have such knowledge or experience. 
> Best regards,
> /Staffan
> ---
> Staffan Kerker, 
> Saab Communication
> Ljungadalsgatan 2, 35180 Växjö, Sweden
> p. +46 470 42185
> c. +46 705 391365
> m. staffan.kerker at saabgroup.com
> w. http://www.saabgroup.com 
> _______________________________________________
> Users mailing list
> Users at openser.org
> http://openser.org/cgi-bin/mailman/listinfo/users

More information about the sr-users mailing list