[SR-Users] [sr-dev] SOS!! Kamailio 3.1.x Load Balancer doesn't work

chanea chanea at gmail.com
Sun Feb 24 13:20:59 CET 2013


Dear Klaus ,

Sorry ,  still stuck in this issue.
The part is still not correctly recorded in the server side behind LB for
REGISTER method.

Following your advice, my config file has been changed as below ,  anything
wrong ??

===========================================================

####### Routing Logic ########


# main request routing logic

route {

# per request initial checks
route(REQINIT);

# NAT detection
route(NAT);

# handle requests within SIP dialogs
route(WITHINDLG);

### only initial requests (no To tag)

# CANCEL processing
if (is_method("CANCEL"))
{
if (t_check_trans())
t_relay();
exit;
}

t_check_trans();

# 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();

# account only INVITEs
if (is_method("INVITE"))
{
setflag(1); # do accounting
}

# dispatch destinations
route(DISPATCH);

route(RELAY);
}


route[RELAY] {
#!ifdef WITH_NAT
if (check_route_param("nat=yes")) {
setbflag(FLB_NATB);
}
if (isflagset(FLT_NATS) || isbflagset(FLB_NATB)) {
route(RTPPROXY);
}
#!endif



if (!t_relay()) {
sl_reply_error();
}

 exit;
}


# Per SIP request initial checks
route[REQINIT] {
if (!mf_process_maxfwd_header("10")) {
sl_send_reply("483","Too Many Hops");
exit;
}

if(!sanity_check("1511", "7"))
{
xlog("Malformed SIP message from $si:$sp\n");
exit;
}
}

# Caller NAT detection route
route[NAT] {
force_rport();
if (nat_uac_test("19")) {
#xlog("L_INFO","ALERT: ua is behind NAT (ru:$ru)(IP:$si:$sp)\n");

if (method=="REGISTER") {
fix_nated_register();
} else {
fix_nated_contact();
}
setflag(FLT_NATS);
}
return;
}

# RTPProxy control
route[RTPPROXY] {
if (is_method("BYE")) {
unforce_rtp_proxy();
} else if (is_method("INVITE")){
xlog("L_INFO","ALERT: force_rtp_proxy called\n");

force_rtp_proxy();
}
if (!has_totag()) add_rr_param(";nat=yes");
return;
}



# Handle requests within SIP dialogs
route[WITHINDLG] {
if (has_totag()) {
# sequential request withing a dialog should
# take the path determined by record-routing
if (loose_route()) {
if (is_method("BYE")) {
setflag(1); # do accounting ...
setflag(3); # ... even if the transaction fails
}
route(RELAY);
} else {
if (is_method("SUBSCRIBE") && uri == myself) {
# in-dialog subscribe requests
route(PRESENCE);
exit;
}
if ( is_method("ACK") ) {
if ( t_check_trans() ) {
# non loose-route, but stateful ACK;
# must be ACK after a 487 or e.g. 404 from upstream server
t_relay();
exit;
} else {
# ACK without matching transaction ... ignore and discard.
exit;
}
}
sl_send_reply("404","Not here");
}
exit;
}
}

# Dispatch requests
route[DISPATCH] {
# round robin dispatching on gateways group '1'
if(!ds_select_dst("1", "0"))
{
send_reply("404", "No destination");
exit;
}
xlog("L_INFO", "--- SCRIPT: going to <$ru> via <$du>\n");
t_on_failure("RTF_DISPATCH");
return;
}

# Sample failure route
failure_route[RTF_DISPATCH] {
if (t_is_canceled()) {
exit;
}
# next DST - only for 500 or local timeout
if (t_check_status("500")
or (t_branch_timeout() and !t_branch_replied()))
{
if(ds_next_dst())
{
t_on_failure("RTF_DISPATCH");
route(RELAY);
exit;
}
}
}

===========================================================




On Fri, Feb 22, 2013 at 12:35 AM, Klaus Darilion <
klaus.mailinglists at pernau.at> wrote:

> Are the clients behind NAT? If yes, you have to use proper NAT traversal
> on the LB. Further, for outgoing INVITEs you have to route the requests
> through the LB, either by static forwarding to the LB or using the Path
> extension.
>
> regards
> Klaus
>
>
> On 21.02.2013 12:36, chanea wrote:
>
>> Dear All,
>>
>> I am trying to use Kamailio 3.1.x  server (called LB here) as the Load
>> Balancer for two other Kamailio server (called server01 and server02
>> here) .
>>
>> Client  A   -----> Kamailio  LB   -----> Kamailio server01
>> Client  B   -----> Kamailio LB   -----> Kamailio server01
>>
>> If I dont use LB here ,  and letting Client A and B connect to  Kamailio
>> server01 directly , all the communication is fine.
>>
>> While using  Kamailio  LB ,without luck, although the sip client  A and
>> B get 200 from server01 for Register,
>> they cannot reach each other for "Message" and "Invite".
>>
>> It will be great appreciated if anyone can give a hint.
>>
>> my config  for Kamailio LB is as below  :
>> ==============================**============
>> ....
>> debug=2          # debug level (cmd line: -dddddddddd)
>> fork=yes
>> log_stderror=yes  # (cmd line: -E)
>>
>> children=2
>> check_via=no      # (cmd. line: -v)
>> dns=off           # (cmd. line: -r)
>> rev_dns=off       # (cmd. line: -R)
>> port=5060
>>
>> # for more info: sip_router -h
>>
>> # ------------------ module loading ------------------------------**----
>> mpath="/usr/local/lib64/**kamailio/modules_k/:/usr/**
>> local/lib64/kamailio/modules/"
>>
>> loadmodule "sl.so"
>> loadmodule "tm.so"
>> loadmodule "rr.so"
>> loadmodule "maxfwd.so"
>> loadmodule "usrloc.so"
>> loadmodule "registrar.so"
>> loadmodule "textops.so"
>> loadmodule "mi_fifo.so"
>> loadmodule "dispatcher.so"
>> loadmodule "db_mysql.so"
>>
>>
>> # ----------------- setting module-specific parameters ---------------
>> # -- dispatcher params --
>> modparam("mi_fifo", "fifo_name", "/tmp/openser_fifo")
>> modparam("dispatcher", "db_url","mysql://.........@..**......")
>> modparam("usrloc", "db_mode",   0)
>> modparam("rr", "enable_full_lr", 1)
>>
>> route{
>> if (!mf_process_maxfwd_header("**10")) {
>>                  sl_send_reply("483","Too Many Hops");
>>                  exit;
>>          };
>>
>>         #  if (!method=="REGISTER")
>>         #        record_route();
>> ds_select_dst("1","4");
>>       forward();
>>
>>       exit;
>>
>> }
>> ..
>> ==============================**============
>>
>>
>> best regards,
>>
>> chanea
>>
>>
>>
>> ______________________________**_________________
>> sr-dev mailing list
>> sr-dev at lists.sip-router.org
>> http://lists.sip-router.org/**cgi-bin/mailman/listinfo/sr-**dev<http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-dev>
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sip-router.org/pipermail/sr-users/attachments/20130224/a27dc834/attachment.htm>


More information about the sr-users mailing list