[OpenSIPS-Users] Load Balancer Script - Looping
Alec Fett
al at boberdoo.com
Fri Aug 14 00:10:44 CEST 2009
I'm having some trouble implementing Bogdan's load_balancer tutorial.
The desired behavior is to call the else block (containing xlog("ALL
GATEWAYS DOWN!\n") ) if all gatways are down.
However, something in my script is causing opensips to enter a
continuous loop.
Initially I had "route(1)" in failure_route, which I thought was the
cause. However, this is still an issue when only calling load_balance.
Aug 13 15:43:08 denver12 /usr/local/sbin/opensips[18397]: Saw an
authorized request FROM IP 10.1.10.76 TO sip:user at 10.1.10.76:5060
.............................many more of
these...................................
Aug 13 15:43:08 denver12 /usr/local/sbin/opensips[18397]: Saw an
authorized request FROM IP 10.1.10.76 TO sip:user at 10.1.10.76:5060
Aug 13 15:43:08 denver12 /usr/local/sbin/opensips[18397]: Looping
detected Sent 483: Looping
(where 10.1.10.76 is openSIPS's ip)
Any suggestions?
Thanks in Advance.
-Alec
----------------------------------------------------------------------------------------
route{
route(1);
}
route[1]{
####IP AUTH##############
if( src_ip==10.1.10.0/24 ){
route(2);
}
else{
sl_send_reply("403","Forbidden");
xlog("L_INFO", "Unauthorized IP address $si TO $ou Sent 403\n");
exit;
}
}
route[2]{
xlog("Saw an authorized request FROM IP $si TO $ou");
if (!mf_process_maxfwd_header("3")) {
sl_send_reply("483","looping");
xlog("Looping detected Sent 483: Looping\n");
exit;
}
if (!has_totag()) {
# initial request
record_route();
} else {
# sequential request -> obey Route indication
loose_route();
t_relay();
exit;
}
# handle cancel and re-transmissions
if ( !t_check_trans() ) {
if (is_method("CANCEL"))
exit;
}
# from now on we have only the initial requests
if (!is_method("INVITE")) {
send_reply("405","Method Not Allowed");
exit;
}
# detect resources and do balancing
# looks like an IPR call
if(load_balance("1","ipr")){
t_on_failure("1");
}
else{
xlog("ALL GATEWAYS DOWN!\n");
exec_msg("/usr/bin/php /usr/scripts/sip-failed.php
all_destinations_down_1 '$si' '$rU' '$fu'");
sl_send_reply("500","Service full");
exit;
}
# LB function returns negative if no suitable destination (for
requested resources) is found,
# or if all destinations are full
if ($retcode<0) {
xlog("Gateway down!\n");
exec_msg("/usr/bin/php /usr/scripts/sip-failed.php
service_full '$si' '$rU' '$fu'");
sl_send_reply("500","Service full");
exit;
}
xlog("Selected destination is: $du\n");
# send it out
if (!t_relay()) {
exec_msg("/usr/bin/php /usr/scripts/sip-failed.php
t_relay_failure '$si' '$rU' '$fu'");
sl_reply_error();
}
}
failure_route[1]{
xlog("Gateway down!\n");
exec_msg("/usr/scripts/sip-failed.php gateway_down '$si' '$rU' '$fu'");
lb_disable();
load_balance("1","ipr");
}
More information about the Users
mailing list