[SR-Users] How to limit number of calls in Kamailio proxy

Andrew Pogrebennyk apogrebennyk at sipwise.com
Mon Oct 31 12:07:38 CET 2011


Austin,
That is strange, because I am using similar setup successfully. Actually
I don't know if it counts the calls that are being established, I didn't
care for it.

While looking through the docs:
http://kamailio.org/docs/modules/3.1.x/modules_k/dialog.html#id2524304
 the following note caught my eye:

IMPORTANT: Users of this function should make sure that the dialog
created is further processed statefully. Specifically, if a stateless
response is sent out after dlg_manage() is called, the dialog cannot be
handled properly. So make sure that a transaction exists or create it
explicitly using the tm module. This is a shortcoming of the current
implementation that may be resolved in a future version hopefully.

Could it be that you are forwarding the INVITE statelessly?
Regards,
Andrew

On 10/30/2011 01:08 PM, Austin Einter wrote:
> Thanks Andrew
> I added profile_with_value module parameter and with that I am able to
> overcome this error.
>  
> My code looks as below.
>  
>         dlg_manage();
>         if (is_method("INVITE")) {
>                  if (!has_totag()) {
>                         #$var(SIZE) = 0;
>                         get_profile_size("caller", "$fu", "$var(SIZE)");
>                         xlog("Number of calls present now is 
> $var(SIZE)\n");
>                         if( $var(SIZE) > MAX_NUMBER_OF_CALLS ) {
>                                 sl_send_reply("503", "Simultaneous calls
> limit reached");
>                                 xlog("Rejected calls with 503
> Simultaneous calls limit reached\n");
>                                 exit;
>                         }
>                         else {
>                                  xlog("Allowed call. Looks max calls
> limit not reached. Calls= $var(SIZE)\n");
>                         }
>                         set_dlg_profile("caller","$fu");
>                 }
>         }
> Whole purpose is to limit number of active calls at any point of time.
> $var(SIZE) gives the number of calls are being established, but not the
> number of calls are already established.
>  
> So if I am making multiple calls at  a point of time, it is blocking
> call attempts beyond limit. But after all call setup complete, again
> $var(SIZE) becomes zero and allows new calls.
>  
>  
> Has anybody done this (limiting number of calls at any point of time).
> If so can you please share the configuration file changes.
>  
>  
> To get $var(SIZE) working properly, do I need to enable MySql, please
> advice.
>  
> Regards
> Austin
> 




More information about the sr-users mailing list