[Freeswitch-users] Limit max concurrent calls on gateways in lua

Zoltán Szabó zoell at zoell.us
Mon Feb 23 01:53:32 MSK 2015


The problem is I don't have any dialplan here, as I start the lua script
with ESL from a different software.

2015-02-22 22:43 GMT+00:00 Stanislav Sinyagin <ssinyagin at gmail.com>:

> the "limit_usage" command should work -- also from fs_cli.
>
> When the "limit" dialplan application changes the current count, a
> corresponding message is printed into debug log, so you should see if
> the limit is set correctly during the call.
>
>
>
> On Sun, Feb 22, 2015 at 6:04 PM, Zoltán Szabó <zoell at zoell.us> wrote:
> > Hi,
> >
> > Thanks but how can I run limit_usage in my case?
> >
> > With this line, the call starts immediately:
> > session1 = freeswitch.Session(dial_call_1);
> >
> > So I need to get the usage info before I start a session. I tried this
> > before the freeswitch.Session but it always returns 0:
> > api = freeswitch.API();
> > local count = api:execute("limit_usage", "hash outbound gw-1");
> >
> > I also tied something like this:
> >
> >     limit_gateway1 = "hash outbound gw-1 3 originate
> sofia/gateway/gw-1/" ..
> > phone;
> >     limit_gateway2 = "hash outbound gw-2 3 originate
> sofia/gateway/gw-2/" ..
> > phone;
> >     limit_gateway3 = "hash outbound gw-3 3 originate
> sofia/gateway/gw-3/" ..
> > phone;
> >
> >     session1 = freeswitch.Session();
> >     session1:execute("limit_execute", limit_gateway1);
> >     session1:execute("limit_execute", limit_gateway2);
> >     session1:execute("limit_execute", limit_gateway3);
> >
> > But it says the session is not initialized when it reaches the first
> > limit_execute line.
> >
> > And unfortunately I don't have any dialplan here as I initiate my calls
> from
> > the lua script. Am I missing something?
> >
> > Many thanks
> >
> > 2015-02-08 15:25 GMT+00:00 Stanislav Sinyagin <ssinyagin at gmail.com>:
> >>
> >> here's what I do in mod_perl, Lua code will be quite similar:
> >>
> >>     $session->execute
> >>         ('set',
> >>          sprintf('user_busy=${cond(${limit_usage(hash %s %s)} > 0 ?
> >> true:false)}',
> >>                  $domain, $availability_username));
> >>     my $user_busy = $session->getVariable('user_busy');
> >>     if( $user_busy eq 'true' )
> >>     {
> >> ......
> >>
> >> also see my blog entry here:
> >>
> >>
> https://txlab.wordpress.com/2013/06/29/freeswitch-limiting-the-number-of-concurrent-calls-on-multiple-sip-accounts/
> >>
> >>
> >> On Sun, Feb 8, 2015 at 1:12 PM, Zoltán Szabó <zoell at zoell.us> wrote:
> >> > Hi,
> >> >
> >> > I have a lua script where I do some business logic. After the logic I
> >> > call a
> >> > number on a gateway, then when the called party picked up, I call an
> >> > other
> >> > number on a gateway and bridge the two calls. The only problem is
> that I
> >> > have 5 gateways and each can have maximum of 3 calls (so I can have 15
> >> > calls
> >> > on this system).
> >> >
> >> > Here is what I have at the moment (simplified version):
> >> >
> >> > dial_call_1 = "{leg=1}sofia/gateway/gw-1/0035312345678";
> >> > dial_call_2 = "{leg=2}sofia/gateway/gw-2/0035387654321";
> >> >
> >> > session1 = freeswitch.Session(dial_call_1);
> >> >
> >> > if (session1:ready()) then
> >> > session2 = freeswitch.Session(dial_call_2, session1);
> >> >
> >> > if (session2:ready()) then
> >> > freeswitch.bridge(session1, session2);
> >> >
> >> > if (session2:ready()) then
> >> > session2:hangup();
> >> > end
> >> > end
> >> >
> >> > if (session1:ready()) then session1:hangup(); end
> >> > end
> >> >
> >> > How can I use the limit application here to set the max concurrent
> calls
> >> > on
> >> > my five gateway, each with 3 max calls and distribute outbound calls
> >> > between
> >> > them?
> >> >
> >> > Many thanks,
> >> > Zoltan
> >> >
> >> >
> >> >
> _________________________________________________________________________
> >> > Professional FreeSWITCH Consulting Services:
> >> > consulting at freeswitch.org
> >> > http://www.freeswitchsolutions.com
> >> >
> >> > Official FreeSWITCH Sites
> >> > http://www.freeswitch.org
> >> > http://confluence.freeswitch.org
> >> > http://www.cluecon.com
> >> >
> >> > FreeSWITCH-users mailing list
> >> > FreeSWITCH-users at lists.freeswitch.org
> >> > http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> >> > UNSUBSCRIBE:
> http://lists.freeswitch.org/mailman/options/freeswitch-users
> >> > http://www.freeswitch.org
> >>
> >>
> _________________________________________________________________________
> >> Professional FreeSWITCH Consulting Services:
> >> consulting at freeswitch.org
> >> http://www.freeswitchsolutions.com
> >>
> >> Official FreeSWITCH Sites
> >> http://www.freeswitch.org
> >> http://confluence.freeswitch.org
> >> http://www.cluecon.com
> >>
> >> FreeSWITCH-users mailing list
> >> FreeSWITCH-users at lists.freeswitch.org
> >> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> >> UNSUBSCRIBE:
> http://lists.freeswitch.org/mailman/options/freeswitch-users
> >> http://www.freeswitch.org
> >
> >
> >
> > _________________________________________________________________________
> > Professional FreeSWITCH Consulting Services:
> > consulting at freeswitch.org
> > http://www.freeswitchsolutions.com
> >
> > Official FreeSWITCH Sites
> > http://www.freeswitch.org
> > http://confluence.freeswitch.org
> > http://www.cluecon.com
> >
> > FreeSWITCH-users mailing list
> > FreeSWITCH-users at lists.freeswitch.org
> > http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> > UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> > http://www.freeswitch.org
>
> _________________________________________________________________________
> Professional FreeSWITCH Consulting Services:
> consulting at freeswitch.org
> http://www.freeswitchsolutions.com
>
> Official FreeSWITCH Sites
> http://www.freeswitch.org
> http://confluence.freeswitch.org
> http://www.cluecon.com
>
> FreeSWITCH-users mailing list
> FreeSWITCH-users at lists.freeswitch.org
> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
> UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
> http://www.freeswitch.org
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20150222/838fc40a/attachment.html 


Join us at ClueCon 2016 Aug 8-12, 2016
More information about the FreeSWITCH-users mailing list