Load balancer retcode question on OpenSIPS 1.6.2

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Load balancer retcode question on OpenSIPS 1.6.2

k1028
I am using OpenSIPS 1.6.2 and followed the tutorial http://www.opensips.org/Resources/DocsTutLoadbalancing to use the load balancer module.
The Tutorial use $retcode<0 for Service Full reply. I get $rectcode = 1 instead of 0. What is the correct retcode load_balance("id","resource") when resource is full?

This work for me
if ( $retcode=1 ) {
sl_send_reply("500","Service full");
exit;
}


Reply | Threaded
Open this post in threaded view
|

Re: Load balancer retcode question on OpenSIPS 1.6.2

k1028
I figured it out.

This work all the time
if ( uri=~"sip:92[1-9][0-9]+@.*" ) {
load_balance("27","white");
} else if ( uri=~"sip:3392[1-9][0-9]+@.*" ) {
load_balance("27","grey"); #
}
if ( $retcode < 0 ) {
sl_send_reply("500","Service full");
exit;
}

This work sometime
if ( uri=~"sip:92[1-9][0-9]+@.*" ) {
load_balance("27","white");
}
if ( uri=~"sip:3392[1-9][0-9]+@.*" ) {
load_balance("27","grey"); #
}
if ( $retcode < 0 ) {
sl_send_reply("500","Service full");
exit;
}
Reply | Threaded
Open this post in threaded view
|

Re: Load balancer retcode question on OpenSIPS 1.6.2

Bogdan-Andrei Iancu
Hi,

your code is not correct as the $retcode returns the ret code of the
last executed instruction, including the "if" statement - to have a
correct code, you need to save the $retcode value immediately after the
call of load_balance() function....

Most probably the "1" val you see is the "true" return code of the "if"
code. Try:

if ( uri=~"sip:92[1-9][0-9]+@.*" ) {
    load_balance("27","white");
    $var(x) = $retcode;
} else if ( uri=~"sip:3392[1-9][0-9]+@.*" ) {
    load_balance("27","grey"); #
    $var(x) = $retcode;
}
if ( $var(x) < 0 ) {
    sl_send_reply("500","Service full");
    exit;
}


Regards,
Bogdan

k1028 wrote:

> I figured it out.
>
> This work all the time
> if ( uri=~"sip:92[1-9][0-9]+@.*" ) {
> load_balance("27","white");
> } else if ( uri=~"sip:3392[1-9][0-9]+@.*" ) {
> load_balance("27","grey"); #
> }
> if ( $retcode < 0 ) {
> sl_send_reply("500","Service full");
> exit;
> }
>
> This work sometime
> if ( uri=~"sip:92[1-9][0-9]+@.*" ) {
> load_balance("27","white");
> }
> if ( uri=~"sip:3392[1-9][0-9]+@.*" ) {
> load_balance("27","grey"); #
> }
> if ( $retcode < 0 ) {
> sl_send_reply("500","Service full");
> exit;
> }
>
>  


--
Bogdan-Andrei Iancu
OpenSIPS Bootcamp
20 - 24 September 2010, Frankfurt, Germany
www.voice-system.ro


_______________________________________________
Users mailing list
[hidden email]
http://lists.opensips.org/cgi-bin/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: Load balancer retcode question on OpenSIPS 1.6.2

k1028
Thanks for your recommendation it work great :).