[Freeswitch-users] Need to set and get Global vairables from dialplan

Ken Rice krice at freeswitch.org
Thu Mar 24 07:49:05 MSK 2016


Are you just trying to round Robin loadbalance?
Why not use mod distributor?
Sent from my iPhone

> On Mar 23, 2016, at 11:17 PM, Varsha Agarwal <vagarwal at vertical.com> wrote:
> 
> This does nor work either. Basically the problem is not with syntax it is with the way these conditions are evaluated. IT is going to parent condition before child condition. So Anti-action always gets executed. I tried it lot of different ways but result seems to be the same. Is it some sort of bug?
>  
> From: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Brian West
> Sent: Wednesday, March 23, 2016 2:29 PM
> To: FreeSWITCH Users Help
> Subject: Re: [Freeswitch-users] Need to set and get Global vairables from dialplan
>  
>  <regex field="${current_node}" expression="^1"/>
>  
> /b
>  
>  
> On Wed, Mar 23, 2016 at 3:01 PM, Varsha Agarwal <vagarwal at vertical.com> wrote:
> Tried this
>  
> <extension name="balance_load">
>       <condition regex="any" break="never">
>                 <action application="log" data="INFO *********LOG LEVEL******** [${current_node}]"  inline="true"/>
>                 <regex field="current_node" expression="^1"/>
>                 <action application="set" data="current_node=2" inline="true"/>
>                 <anti-action application="set" data="current_node=1" inline="true"/>
>                 <action application="log" data="INFO *********LOG LEVEL******** [${current_node}]"  inline="true"/>
>       </condition>
>       <condition field="destination_number" expression="^5050$">
>                 <action application="set" data="continue_on_fail=true"/>
>                 <action application="set" data="hangup_after_bridge=true"/>
>                 <action application="log" data="INFO *********LOG LEVEL******** [${current_node}]"  inline="true"/>
>                 <regex field="current_node" expression="^1"/>
>                 <action application="bridge" data="loopback/5000"/>
>                 <anti-action application="bridge" data="sofia/external/5000 at 172.18.19.72"/>
>                                
>       </condition>
>  
> Did not work either. No matter what is the value for current_node, always executes "anti-action".
>  
> From: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Brian West
> Sent: Wednesday, March 23, 2016 11:41 AM
> 
> To: FreeSWITCH Users Help
> Subject: Re: [Freeswitch-users] Need to set and get Global vairables from dialplan
>  
> try not nesting your conditions and stack them instead.
>  
> On Wed, Mar 23, 2016 at 2:12 PM, Varsha Agarwal <vagarwal at vertical.com> wrote:
> Thanks for the reply. I changed dialplan as following and still same results
>  
> <!--Sample load balancing-->
>     <extension name="balance_load">
>       <condition field="destination_number" expression="^5050$">
>                 <action application="set" data="continue_on_fail=true"/>
>                 <action application="set" data="hangup_after_bridge=true"/>
>                 <action application="log" data="INFO *********LOG LEVEL******** [${current_node}]"/>
>                 <condition field="${current_node}" expression="^1$">
>                                 <action="set" data="current_node=2"  inline="true"/>
>                                 <action application="log" data="INFO *********LOG LEVEL******** [${current_node}]"/>
>                                 <action application="bridge" data="loopback/5000"/>
>                 </condition>
>                 <condition field="${current_node}" expression="^2$">
>                                 <action="set" data="current_node=1"  inline="true"/>
>                                 <action application="log" data="INFO *********LOG LEVEL******** [${current_node}]"/>
>                                 <action application="bridge" data="sofia/external/5000 at 172.18.19.72"/>
>                 </condition>
>                 <action="set" data="current_node=2"  inline="true"/>
>                 <action application="log" data="INFO *********LOG LEVEL AFTER******** [${current_node}]"/>
>                 <action application="bridge" data="loopback/5000"/>
>                
>       </condition>
>     </extension>
>  
> Interestingly this is what I see in Freeswitch traces
> 2016-03-23 11:07:22.895579 [INFO] mod_dptools.c:1692 *********LOG LEVEL******** [1]
> 2016-03-23 11:07:22.895579 [INFO] mod_dptools.c:1692 *********LOG LEVEL AFTER******** [1]
> 2016-03-23 11:07:22.895579 [INFO] mod_loopback.c:1075 Sending early media
>  
> Even if value for "current_node" is 1 it does not go to <condition field="${current_node}" expression="^1$"> condition. At least it should go there.
>  
> From: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Ken Rice
> Sent: Wednesday, March 23, 2016 6:07 AM
> To: 'FreeSWITCH Users Help'
> Subject: Re: [Freeswitch-users] Need to set and get Global vairables from dialplan
>  
> As with any variables (channel or global) variables are expanded when the dialplan is processed, then a list of actions is built, based on conditions that are met. This is called the Routing Stage in FreeSWITCH Call Processing.
> One that Routing Stage is completed, then we move to the Execute Stage where the Actions (or anti-actions) that were added to the list of things to do are executed.
>  
> In your example the vars are expanded before the set and log application actions are actually executed.
>  
> See https://freeswitch.org/confluence/display/FREESWITCH/XML+Dialplan and look for inline=”true” for a more complete explanation on way to do what you are trying.
>  
>  
> From: freeswitch-users-bounces at lists.freeswitch.org [mailto:freeswitch-users-bounces at lists.freeswitch.org] On Behalf Of Varsha Agarwal
> Sent: Wednesday, March 23, 2016 12:47 AM
> To: FreeSWITCH-users at lists.freeswitch.org
> Subject: [Freeswitch-users] Need to set and get Global vairables from dialplan
>  
> Hi,
>  
> I have created a variable in var.xml, current_node. I am trying to use it in dialplan as below, is this something I can do?
>  
> <extension name="balance_load">
>       <condition field="destination_number" expression="^5050$">
>                 <action application="set" data="continue_on_fail=true"/>
>                 <action application="set" data="hangup_after_bridge=true"/>
>                 <action application="log" data="INFO *********LOG LEVEL******** [${current_node}]"/>
>                 <condition field="current_node" expression="^1$">
>                                 <action="set_global" data="current_node=2"/>
>                                 <action application="log" data="INFO *********LOG LEVEL******** [${current_node}]"/>
>                                 <action application="bridge" data="loopback/5000"/>
>                 </condition>
>                 <condition field="current_node" expression="^2$">
>                                 <action="set_global" data="current_node=2"/>
>                                 <action application="log" data="INFO *********LOG LEVEL******** [${current_node}]"/>
>                                 <action application="bridge" data="sofia/external/5000 at 172.18.19.72"/>
>                 </condition>
>                 <action="set_global" data="current_node=2"/>
>                 <action application="log" data="INFO *********LOG LEVEL AFTER******** [${current_node}]"/>
>                 <action application="bridge" data="loopback/5000"/>
>                
>       </condition>
>     </extension>
>  
> Currently log always print current_node = 1 which is the value set in vars.xml.
>  
> Thanks,
> Varsha
> 
> _________________________________________________________________________
> 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
> 
> 
>  
> --
> Brian West
> brian at freeswitch.org
> 
> 
> 
> Twitter: @FreeSWITCH , @briankwest
> http://www.freeswitchbook.com
> http://www.freeswitchcookbook.com
> https://www.gofundme.com/freeswitch_ubuntu
> 
> Got Bugs? Report them here! | Reddit: /r/freeswitch
> 
> T:+19184209001 | F:+19184209002 | M:+1918424WEST (9378)
> iNUM:+883 5100 1420 9001 | ISN:410*543 | Skype:briankwest
> 
> 
> _________________________________________________________________________
> 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
> 
> 
>  
> --
> Brian West
> brian at freeswitch.org
> 
> 
> 
> Twitter: @FreeSWITCH , @briankwest
> http://www.freeswitchbook.com
> http://www.freeswitchcookbook.com
> https://www.gofundme.com/freeswitch_ubuntu
> 
> Got Bugs? Report them here! | Reddit: /r/freeswitch
> 
> T:+19184209001 | F:+19184209002 | M:+1918424WEST (9378)
> iNUM:+883 5100 1420 9001 | ISN:410*543 | Skype:briankwest
> 
> _________________________________________________________________________
> 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/20160323/98a5b45d/attachment-0001.html 


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