<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'>
<html><head><meta http-equiv="Content-Type" content="text/html;charset=us-ascii">
<style>BODY{font:10pt Tahoma, Verdana, sans-serif}</style></head><body>
<DIV>One trick I've noticed that nobody is doing for outbound limit, is using "execute_on_originate" to do the limit there on each channel. You can specify it in the local variables per channel. <BR><BR>The following would do it for each B-Leg, w/o messing associating the coun't to your a-leg session:</DIV>
<DIV> </DIV>
<DIV>bridge:[execute_on_originate=limit hash foo gwa 10]sofia/gateway/gwa/$1|[execute_on_originate=limit hash foo gwb 10]sofia/gateway/gwb/$1 ... and so on...</DIV>
<DIV> </DIV>
<DIV>I use this all the time in a more extended way. I use execute_on_originate to call my own dialplan app, but you could use it to invoke a lua script as well on the session of the B-Leg, before the call is originated. If you just return from your dialplan app, the b-leg will continue, but if you hangup the channel, then it will look like the b-leg failed with the hangup cause you specify, and will get passed back as if the far end returned that cause.</DIV>
<DIV> </DIV>
<DIV>--Dave</DIV><BR>
<BLOCKQUOTE style="BORDER-LEFT: #0000ff 2px solid; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; MARGIN-RIGHT: 0px">
<HR>
<B>From:</B> Muhammad Naseer Bhatti [mailto:nbhatti@gmail.com]<BR><B>To:</B> FreeSWITCH Users Help [mailto:freeswitch-users@lists.freeswitch.org]<BR><B>Sent:</B> Tue, 29 May 2012 14:12:01 -0700<BR><B>Subject:</B> Re: [Freeswitch-users] Gateway failover with LUA<BR><BR>They are two different gateways with two different names, but the same<BR>IP address yet the port is different. Possible that limit subsystem is<BR>imposing the limit on the IP address itself and not able to<BR>distinguish between the different ports.<BR><BR>On Tue, May 29, 2012 at 11:49 PM, Muhammad Naseer Bhatti<BR><<A href="mailto:nbhatti@gmail.com">nbhatti@gmail.com</A>> wrote:<BR>> Possible but here is the problem. When limit is set against two of the<BR>> gateways,<BR>><BR>> session:execute("limit", "hash gateway_channels v132_5000 10")<BR>> session:execute("limit", "hash gateway_channels v132_5010 10")<BR>><BR>> It sets limit of 10 channels for each gateway. But when the bridge is made,<BR>><BR>> [gateway=v132_5010]sofia/gateway/v132_5010/9198|[gateway=v132_5000]sofia/gateway/v132_5000/9198<BR>><BR>> The limit is imposed on both gateways.<BR>><BR>> 2012-05-27 22:13:48.371539 [INFO] switch_limit.c:126 incr called:<BR>> gateway_channels_v132_5000 max:10, interval:0<BR>> 2012-05-27 22:13:48.371539 [INFO] mod_hash.c:202 Usage for<BR>> gateway_channels_v132_5000 is now 3/10<BR>> 2012-05-27 22:13:48.371539 [INFO] switch_limit.c:126 incr called:<BR>> gateway_channels_v132_5010 max:10, interval:0<BR>> 2012-05-27 22:13:48.371539 [INFO] mod_hash.c:202 Usage for<BR>> gateway_channels_v132_5010 is now 3/10<BR>><BR>> Is this is a bug or supposed to work like this? Though the call is<BR>> connected to gateway name v132_5010 only.<BR>><BR>><BR>> Thanks.<BR>><BR>> On Mon, May 28, 2012 at 7:20 PM, Avi Marcus <<A href="mailto:avi@avimarcus.net">avi@avimarcus.net</A>> wrote:<BR>>> How about a bridge2, bridge3, etc variable? Then your static dialplan can<BR>>> see if those are set, and if so, use them.<BR>>><BR>>> -Avi<BR>>><BR>>><BR>>> On Mon, May 28, 2012 at 1:09 PM, Muhammad Naseer Bhatti <<A href="mailto:nbhatti@gmail.com">nbhatti@gmail.com</A>><BR>>> wrote:<BR>>>><BR>>>> Hi, I am trying to implement a gateway failover functionality with<BR>>>> lua. Right now I am using limit and using hash backend to limit number<BR>>>> of channels to each gateway. Since I am forwarding all calls with a<BR>>>> default dialplan which is sending all calls to application lua and the<BR>>>> bridge is done outside lua setting all the necessary vars.<BR>>>> The idea is if all channels of first gateway are occupied, send the<BR>>>> call to second gateway in the list and so on. Any idea how to<BR>>>> implement this with lua? Can not seem to find the logic. If I query<BR>>>> with limit_status it is going to be a query on every call. In a high<BR>>>> call volume scenario, I don't think this would be really a good<BR>>>> choice. Any ideas, thoughts?<BR>>>><BR>>>> Thanks.<BR>>>><BR>>>> _________________________________________________________________________<BR>>>> Professional FreeSWITCH Consulting Services:<BR>>>> <A href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</A><BR>>>> <A href="http://www.freeswitchsolutions.com/" target=_blank>http://www.freeswitchsolutions.com</A><BR>>>><BR>>>> FreeSWITCH-powered IP PBX: The CudaTel Communication Server<BR>>>> <A href="http://www.cudatel.com/" target=_blank>http://www.cudatel.com</A><BR>>>><BR>>>> Official FreeSWITCH Sites<BR>>>> <A href="http://www.freeswitch.org/" target=_blank>http://www.freeswitch.org</A><BR>>>> <A href="http://wiki.freeswitch.org/" target=_blank>http://wiki.freeswitch.org</A><BR>>>> <A href="http://www.cluecon.com/" target=_blank>http://www.cluecon.com</A><BR>>>><BR>>>> Join Us At ClueCon - Aug 7-9, 2012<BR>>>><BR>>>> FreeSWITCH-users mailing list<BR>>>> <A href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</A><BR>>>> <A href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target=_blank>http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</A><BR>>>> UNSUBSCRIBE:<A href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target=_blank>http://lists.freeswitch.org/mailman/options/freeswitch-users</A><BR>>>> <A href="http://www.freeswitch.org/" target=_blank>http://www.freeswitch.org</A><BR>>><BR>>><BR>>><BR>>> _________________________________________________________________________<BR>>> Professional FreeSWITCH Consulting Services:<BR>>> <A href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</A><BR>>> <A href="http://www.freeswitchsolutions.com/" target=_blank>http://www.freeswitchsolutions.com</A><BR>>><BR>>> FreeSWITCH-powered IP PBX: The CudaTel Communication Server<BR>>> <A href="http://www.cudatel.com/" target=_blank>http://www.cudatel.com</A><BR>>><BR>>> Official FreeSWITCH Sites<BR>>> <A href="http://www.freeswitch.org/" target=_blank>http://www.freeswitch.org</A><BR>>> <A href="http://wiki.freeswitch.org/" target=_blank>http://wiki.freeswitch.org</A><BR>>> <A href="http://www.cluecon.com/" target=_blank>http://www.cluecon.com</A><BR>>><BR>>> Join Us At ClueCon - Aug 7-9, 2012<BR>>><BR>>> FreeSWITCH-users mailing list<BR>>> <A href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</A><BR>>> <A href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target=_blank>http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</A><BR>>> UNSUBSCRIBE:<A href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target=_blank>http://lists.freeswitch.org/mailman/options/freeswitch-users</A><BR>>> <A href="http://www.freeswitch.org/" target=_blank>http://www.freeswitch.org</A><BR>>><BR><BR>_________________________________________________________________________<BR>Professional FreeSWITCH Consulting Services:<BR><A href="mailto:consulting@freeswitch.org">consulting@freeswitch.org</A><BR><A href="http://www.freeswitchsolutions.com/" target=_blank>http://www.freeswitchsolutions.com</A><BR><BR>FreeSWITCH-powered IP PBX: The CudaTel Communication Server<BR><A href="http://www.cudatel.com/" target=_blank>http://www.cudatel.com</A><BR><BR>Official FreeSWITCH Sites<BR><A href="http://www.freeswitch.org/" target=_blank>http://www.freeswitch.org</A><BR><A href="http://wiki.freeswitch.org/" target=_blank>http://wiki.freeswitch.org</A><BR><A href="http://www.cluecon.com/" target=_blank>http://www.cluecon.com</A><BR><BR>Join Us At ClueCon - Aug 7-9, 2012<BR><BR>FreeSWITCH-users mailing list<BR><A href="mailto:FreeSWITCH-users@lists.freeswitch.org">FreeSWITCH-users@lists.freeswitch.org</A><BR><A href="http://lists.freeswitch.org/mailman/listinfo/freeswitch-users" target=_blank>http://lists.freeswitch.org/mailman/listinfo/freeswitch-users</A><BR>UNSUBSCRIBE:<A href="http://lists.freeswitch.org/mailman/options/freeswitch-users" target=_blank>http://lists.freeswitch.org/mailman/options/freeswitch-users</A><BR><A href="http://www.freeswitch.org/" target=_blank>http://www.freeswitch.org</A><BR></BLOCKQUOTE>
<STYLE>
</STYLE>
<DIV> </DIV>
<DIV> </DIV></body></html>