[OpenSIPS-Users] Timer based Failover to SIP Provider

Duane Larson duane.larson at gmail.com
Mon May 23 23:41:26 CEST 2011


I am trying to set up some logic that will allow me to failover to a
secondary SIP Provider's IP address and I found this subject on how you can
implement it

http://opensips-open-sip-server.1449251.n2.nabble.com/Timer-Based-Failover-Question-td5758903.html


In order to test I send my first call to 4.2.2.X (which is not my SIP
providers Gateway).  So this call fails as planned.  Then a second call is
sent to the correct backup SIP Providers IP address.  This call starts to go
through but then my Timer times out and the call is canceled.  I am not sure
why the call is canceled because I get a 183 from the SIP provider and in my
OnReply_Route I set the timeout to be 300 seconds.  It seems like when I set
fr_inv_timer_avp it doesn't take affect.  Not sure what I am doing wrong.
Here is what I do

route[4] {
        # routing to the public network
        $du = "sip:" + $rU + "@173.X.X.88:5060";  # IP Address of my
OpenSIPS B2BUA server
        $ru = "sip:" + $rU + "@4.2.2.2:5060";
        append_rpid_hf();  # Append Remote-Party-ID header field

        t_on_reply("2");
        t_on_failure("2");
        $avp(s:fr_inv_timer) = 6;
        if (!t_relay()) {
                sl_reply_error();
        };
        exit;
}

onreply_route[2] {
        #
        #-- On-reply block routing --
        #
        append_hf("P-hint: Onreply-route 2 - fixcontact \r\n");
        fix_contact();
        if ( $rs =~ "18." ) {
                $avp(s:fr_inv_timer) = 300;
        }
        exit;
}


failure_route[2] {
xlog("L_INFO", "Failure Route 2: Call [$rm] rU[$rU] ru[$ru] rd[$rd] fu[$fu]
tu[$tu] si[$si] ct[$ct]\n");
        ##--
        ##-- If cancelled, exit.
        ##--
        if (t_was_cancelled()) {
                exit;
        };

        # -- The last call failed to the Primary SIP Trunk Gateway
        # -- So we need to try the Backup SIP Trunk Gateway
        $du = "sip:" + $rU + "@173.X.X.X:5060";
        $ru = "sip:" + $rU + "@216.82.225.202:5060";  #Bandwidth.com's
Secondary SIP Gateway
        append_rpid_hf();  # Append Remote-Party-ID header field

        $avp(s:fr_inv_timer) = 6;
        t_on_reply("2");
        t_on_failure("3");
        t_relay();
        exit;
}

failure_route[3] {
        ##--
        ##-- If cancelled, exit.
        ##--
        if (t_was_cancelled()) {
                exit;
        };
        ##--
        ##-- If the Backup SIP Trunk Gateway didn't answer then we need to
tell user "Server Unavailable"
        t_reply("503","Service not available, no more gateways");
        exit;
}




It seems like I have everything configured correctly so I am not sure why
the second call is being canceled.  Sometimes a phone on the PSTN side will
get the call and I answer the phone but I can't hear anything and then the
call hangs up right away.

I did a ngrep capture on both my OpenSIPS Proxy server and my OpenSIPS B2BUA
server that sits in between my SIP Trunk Provider and my OpenSIPS Proxy

OpenSIPSB2BUA Ngrep  http://pastebin.com/BGEF7YxT
OpenSIPSProxy Ngrep    http://pastebin.com/hfhezZMp

It looks like the OpenSIPS B2BUA sends the OpenSIPS proxy a 183 message and
then 4 200 OK's but the OpenSIPS Proxy never replies back with an ACK.

In the Ngreps my OpenSIPS Proxy is (173.XX.X.107) and my OpenSIPS B2BUA is (
173.XX.X.88).
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20110523/4273a526/attachment.htm>


More information about the Users mailing list