[SR-Users] Load balancer using dispatcher / BYE relaying

martian at centrum.sk martian at centrum.sk
Fri Apr 19 21:57:01 CEST 2013


Hi Ariel.
 
The problem with Your routing logic is that You don't route in-dialog messages.
Basically, Your request_route should look something like this:
 
request_route {
 
 # per request initial checks
 route(REQINIT);
 
 # CANCEL processing
 if (is_method("CANCEL"))
 {
 if (t_check_trans())
 t_relay();
 exit;
 }
 
 # handle requests within SIP dialogs
 route(WITHINDLG);
 
 # record routing for dialog forming requests (in case they are routed)
 # - remove preloaded route headers
 remove_hf("Route");
 if (is_method("INVITE|SUBSCRIBE"))
 record_route();
 
 if ($rU==$null)
 {
 # request with no Username in RURI
 sl_send_reply("484","Address Incomplete");
 exit;
 }
 
 if (is_method("INVITE"))
 route(LOADBALANCE);
 
 route(RELAY);
}
 
There is a lot of things (like initial messages checks) that should be done before routing the message to Media server.
As You can see, route(WITHINDLG) is called even before route(LOADBALANCE). This ensures that messages following the INVITE (BYE included) will be routed
to Media server (which will solve your problem).
However, when calling route(WITHINDLG) You should take care when recieving INVITE with preloaded set of Route headers. They might cause Kamailio to consider the INVITE
within other dialog and route it incorectly (completely bypassing the Media server).
It is also a good practice to use the DIALOG module to keep track about ongoing calls and log them in the database (for example).

The request_route I wrote above might require some customization from You, in order to take care about requests You don't wish to forward to
Media servers (such as Presence related requests and so on..).
 
In route(LOADBALANCE) you should have something like this:
 
route[LOADBALANCE] {
 if(!ds_select_dst("0", "4"))
 {
 xlog("L_NOTICE", "---- No Media server available! sending 404 and exiting.");
 send_reply("404", "No destination");
 exit;
 }
 xlog("L_DBG", "--- Media server selected! Going to <$ru> via <$du>\n");
 #for failure speed:
 t_set_fr(0,2000);
 return;
}
 
Your failure_route looks ok, no changes there I would say.
 
Cheers,
Martin
______________________________________________________________
> Od: "Ariel Wainer" <awainer at contentamobile.com>
> Komu: <sr-users at lists.sip-router.org>
> Dátum: 19.04.2013 17:43
> Predmet: [SR-Users] Load balancer using dispatcher / BYE relaying
>
StartFragmentHi, I'm new to Kamailio and I'm trying to setup a load
balancer using Kamailio 4.0 and rtpproxy, to balance between 2 asterisk
servers that provide an IVR service.

I've followed several guides, and so far it seems to work along with
rtpproxy, except it is not sending the BYE message back to asterisk, and
the call never finishes from the asterisk POV.
Let me describe the test scenario: I have the following:
IP phone: 192.168.200.183
PBX: 192.168.200.3
Kamailio: 192.168.200.132
IVR1: 192.168.200.160

IVR2: 192.168.200.161




More information about the sr-users mailing list