[OpenSIPS-Users] load_balancer module retcode

k1028 mrprotocols at gmail.com
Fri May 8 19:12:27 CEST 2009


I got it to work using 

if ( !load_balance("40","pstn") {
    sl_send_reply("500","Service FUll");
    xlog("L_INFO","Service Full");
    exit;
} 

instead of

load_balance("40","pstn") {
if ($retcode<0 ) {
     sl_send_reply("500","Service full");
     exit;
}


k1028 wrote:
> 
> I tried everything possible and couldn't get the return code to return a
> negative value when it reach the limiation. I have the same problem with
> the sample script from Opensips tutorial for load_balancer.so. The retcode
> is always return back as 18446744073709551614 and instead of negative
> value. 
> 
> 
> Bogdan-Andrei Iancu wrote:
>> 
>> Hi,
>> 
>> I think there is a error in your script....the $retcode returns the 
>> return code of the last used function, but your LB function is much, 
>> much above the retcode testing....
>> 
>> Regards,
>> Bogdan
>> 
>> k1028 wrote:
>>> I am playing with the Load_balancer module at this time. The retcode
>>> does not
>>> return a negative value for me instead it return 18446744073709551614
>>> when
>>> it reach the pstn limit
>>>
>>> I tried with pstn=1 and pstn=2 using 1 peer and 2 peer. All come back
>>> with
>>> the same retcode. 
>>>
>>> I also tried my route script as well as the one from opensips tutorial.
>>> Also
>>> tried google, search forum and looked up tracker not able to find
>>> anything.
>>> Any help would be greatly appreciated
>>>
>>> version: opensips 1.5.1-notls (x86_64/linux)
>>>
>>> this is my route script
>>> # ----- Dialog params -----
>>> modparam("dialog", "dlg_flag", 5)                                       
>>> modparam("dialog", "timeout_avp", "$avp(i:4242)")                      
>>> #Set
>>> AVP timeout variable
>>>
>>> # ----- SST params -----
>>> modparam("sst", "sst_flag", 6)                                         
>>> #Set
>>> SST flag
>>> modparam("sst", "timeout_avp", "$avp(i:4242)")                          
>>> modparam("sst", "min_se", 10800)                                       
>>> #Min
>>> Session Timer
>>>
>>> # ----- QOS params -----
>>> modparam("qos", "qos_flag", 7)                                         
>>> #Set
>>> QoS falg
>>>
>>>
>>> route{
>>>
>>>         if(msg:len > max_len)
>>>         {
>>>                 sl_send_reply("513", "Message Too Big");
>>>                 exit;
>>>         }
>>>
>>>         if (!mf_process_maxfwd_header("3")) {
>>>                 sl_send_reply("483","Too Many Hops");
>>>                 exit;
>>>         }
>>>
>>>         # record routing
>>>         if (!has_totag()) {
>>>                 # initial request
>>>                 record_route();
>>>         } else {
>>>                 # sequential request -> obey Route indication
>>>                 loose_route();
>>>                 t_relay();
>>>                 exit;
>>>         }
>>>
>>>         if ( is_method("INVITE") ) {
>>>                 if (sstCheckMin("1")) {
>>>                         xlog("L_ERR", "422 Session Timer Too Small reply
>>> sent.\n");
>>>                         exit;
>>>                 }
>>>                 # track the session timers via the dialog module
>>>                 setflag(5);
>>>                 setflag(6);
>>>                 setflag(7);
>>>         }
>>>
>>>         if ( uri=~"sip:[0-9][0-9]+ at .*" ) {
>>>                 load_balance("40","pstn");
>>>                 xlog("L_INFO","Selected destination is: $du = $du AND
>>> retcode = $retcode \n\n");
>>>                 route(3);
>>>         }
>>>
>>> route[3] {
>>>
>>>         t_on_reply("1");
>>>
>>>         # 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;
>>>         }
>>>
>>>         # send it out
>>>         if (!t_relay()) {
>>>                 sl_reply_error();
>>>         }
>>>
>>> onreply_route[1]
>>> {
>>>         xlog("L_INFO", "Reply - S=$rs D=$rr F=$fu T=$tu IP=$si
>>> ID=$ci\n\n");
>>>         exit;
>>>
>>> }
>>>
>>>
>>>         exit;
>>> }
>>>
>>>
>>> Level 6 debug message 
>>> May  7 19:59:19 [30633] DBG:load_balancer:do_load_balance: found
>>> requested
>>> (0) resource pstn
>>> May  7 19:59:19 [30633] DBG:dialog:build_new_dlg: new dialog
>>> 0x7f77ae5740a0
>>> (c=2b56f9b707a0f7bb7585ab1655349fc2 at xxxxxxx,f=sip:xxx at xxxxxx,t=sip:xxxxxxxxx at xxxxxxx,ft=as4634cbd6)
>>> on hash 2403
>>> May  7 19:59:19 [30633] DBG:dialog:populate_leg_info: route_set ,
>>> contact
>>> sip:xxxx at xxxxx, cseq 102 and bind_addr udp:xxxxxxxxx:5060
>>> May  7 19:59:19 [30633] DBG:dialog:dlg_set_leg_info: set leg 0 for
>>> 0x7f77ae5740a0: tag=<as4634cbd6> rr=<> ct=<sip:xxxxx at xxxxxxx> cseq=<102>
>>> May  7 19:59:19 [30633] DBG:load_balancer:do_load_balance: destination
>>> <sip:xxxxxxxx> selected for LB set with free=1 (max=1)
>>> xlog Selected destination is: $du = sip:xxxxxxxx AND retcode =1 
>>> May  7 19:59:31 [30633] DBG:dialog:build_new_dlg: new dialog
>>> 0x7f77ae578410
>>> (c=291ea90b4956416b47e7932f067530e0 at xxxxxxx,f=sip:xxxx at xxxxx,t=sip:xxxxx at xxxxxx,ft=as718571da)
>>> on hash 2865
>>> May  7 19:59:31 [30633] DBG:core:parse_headers: flags=400
>>> May  7 19:59:31 [30633] DBG:core:get_hdr_field: content_length=357
>>> May  7 19:59:31 [30633] DBG:core:get_hdr_field: found end of header
>>> May  7 19:59:31 [30633] DBG:dialog:populate_leg_info: route_set ,
>>> contact
>>> sip:xxxxx at xxxxxxx, cseq 102 and bind_addr udp:xxxxxxx:5060
>>> May  7 19:59:31 [30633] DBG:dialog:dlg_set_leg_info: set leg 0 for
>>> 0x7f77ae578410: tag=<as718571da> rr=<> ct=<sip:xxxx at xxxxxx> cseq=<102>
>>> May  7 19:59:31 [30633] DBG:dialog:link_dlg: ref dlg 0x7f77ae578410 with
>>> 3
>>> -> 3
>>> May  7 19:59:31 [30633] DBG:rr:add_rr_param: adding (;did=13b.f0a11e75)
>>> 0x780150
>>> May  7 19:59:31 [30633] DBG:load_balancer:
>>> d_balance: destination <sip:xxxxxxxx> selected for LB set with free=0
>>> (max=0)
>>> May  7 19:59:31 [30633] DBG:load_balancer:do_load_balance: no
>>> destination
>>> found
>>> May  7 19:59:31 [30633] DBG:core:pv_get_dsturi: no destination URI
>>> Selected destination is: $du = <null> AND retcode = 18446744073709551614 
>>>   
>> 
>> 
>> _______________________________________________
>> Users mailing list
>> Users at lists.opensips.org
>> http://lists.opensips.org/cgi-bin/mailman/listinfo/users
>> 
>> 
> 
> 

-- 
View this message in context: http://n2.nabble.com/load_balancer-module-retcode-tp2838151p2846494.html
Sent from the OpenSIPS - Users mailing list archive at Nabble.com.




More information about the Users mailing list