[OpenSIPS-Users] Load balancer and CANCEL requests

Peter P GMX Prometheus001 at gmx.net
Wed Sep 23 10:36:03 CEST 2009


Hello Bogdan,

we only very slightly modified the openser.cfg:
We only added the
REGISTER in
if (!is_method("INVITE") && !is_method("REGISTER")){
in order to balance resgisters to the Freeswitch cluster.

and added
# Load Balancing only for my.domain
if ($td=~"^my.domain") {
in order to handle outbound requests to other phones through OpenSIPS.
This is needed to produce our test case when making a call between 2 phones.

While putting in some debugging lines I found out that
# handle cancel and re-transmissions
if ( !t_check_trans() ) {
if (is_method("CANCEL")) {
is not successful during the cancel request. So !t_check_trans() seems
to be false in that case as ismethod("CANCEL") is not called.
Then is continues the script and sends a 405 message.

Howwver the INVITE and CANCEL reequest had the same call-id.

Here's my opensips.conf:
=========================
debug=1
memlog=1

fork=yes
children=2
log_stderror=no
log_facility=LOG_LOCAL0

disable_tcp=yes
disable_dns_blacklist = yes

auto_aliases=no

check_via=no
dns=off
rev_dns=off

listen=udp:xx.xx.xx.xx:5060
alias=udp:my.domain:5060

mpath="/usr/local/lib64/opensips/modules/"

loadmodule "maxfwd.so"
loadmodule "sl.so"
loadmodule "db_mysql.so"
loadmodule "tm.so"
loadmodule "xlog.so"
loadmodule "uri.so"
loadmodule "rr.so"
loadmodule "dialog.so"
loadmodule "mi_fifo.so"
#loadmodule "mi_xmlrpc.so"
loadmodule "signaling.so"
loadmodule "textops.so"
loadmodule "load_balancer.so"

modparam("mi_fifo", "fifo_name", "/tmp/opensips_fifo")

modparam("dialog", "dlg_flag", 13)
modparam("dialog", "db_mode", 1)
modparam("dialog", "db_url", "mysql://user:pass@localhost/opensips")

modparam("rr","enable_double_rr",1)
modparam("rr","append_fromtag",1)

modparam("load_balancer", "db_url","mysql://user:pass@localhost/opensips")


route{
if (!mf_process_maxfwd_header("3")) {
sl_send_reply("483","looping");
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") && !is_method("REGISTER")){
send_reply("405","Method Not Allowed");
exit;
}

# Load Balancing only for my.domain
if ($td=~"^my.domain") {
# detect resources and do balancing
if ($rU=~"^conference") {
# looks like a Conference call
load_balance("1","conf");
} else if ($rU=~"^voicemail") {
# looks like a VoiceMail call
load_balance("1","vm");
} else {
# Forward to the freeswitches
load_balance("1","freeswitch");
}

# LB function returns negative if no suitable destination (for requested
resources) is found,
# or if all destinations are full
if ($retcode<0) {
sl_send_reply("500","Service full");
exit;
}

xlog("Selected destination is: $du\n");
}

# send it out for all domains
if (!t_relay()) {
sl_reply_error();
}
}


Bogdan-Andrei Iancu schrieb:
> Hello Peter,
>
> First of all the script from the tutorial does LB only for initial 
> requests, requests that are creating a dialog (like INVITE). All other 
> sequential requests (in dialog requests) are routed based on Route 
> header, directly to the FS where the call was sent.
>
> The CANCELs are processed in a stateful way. The CANCELs are matched 
> against the INVITE transaction and automatically sent to the same 
> destination where the INVITE was sent. The relevant script part is:
>
>         # handle cancel and re-transmissions
> 	if ( !t_check_trans() ) {
> 		if (is_method("CANCEL"))
> 			exit;
> 	}
>
>
> So, the script does properly handle the CANCELs and there is nothing 
> else required to make it work.
>
> My question is, using the script as per tutorial (no changes of yours), 
> what happens when OpenSIPS does receive a CANCEL?
>
> Regards,
> Bogdan
>
> Peter P GMX wrote:
>   
>> Hello,
>>
>> I am using the load balancer in front of a Freeswitch cluster.
>> Freeswitch is always in the SIP route.
>> It handles Registers and Invites quite well.
>>
>> However CANCEL is not working according to the tutorial in
>> http://www.opensips.org/index.php?n=Resources.DocsTutLoadbalancing
>>
>> CANCEL requests are aborted with 405 Method Not Allowed.
>> I understand that CANCELS should not be balanced as it cannot be forseen
>> which Freeswitch will receive this CANCEL request, right? Or does the
>> load balancer handle this correctly based on a call id?
>>
>> So I tried to allow CANCEL in
>>
>>  if (!is_method("INVITE") && !is_method("REGISTER")) &&
>> !is_method("CANCEL")) {
>> ...
>>
>> This leads to "500 Service full", means some error occured.
>>
>> Question: How can I handle the CANCEL request correctly?
>>
>> Best regards
>> Peter
>>
>>
>>
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>>
>>   
>>     
>
>
> _______________________________________________
> Users mailing list
> Users at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>
>   



More information about the Users mailing list