Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?
Hello All, I am a newbie to FreeSWITCH, please excuse if this question has already been answered. My requirement is as follows: * When an incoming call is received, it needs to be bridged to one of the 4 available destination lines * Minimal management of these lines is required: need to keep track of when each line was used, so that, when a new incoming call is received, I can use the oldest used available line to bridge the call to In order to achieve this, I have: * Defined a few global variables in vars.xml, which would keep track of each line's status (available/busy) and last used timestamp * Implemented a Lua script which 'chooses' the line based on global variables status and timestamp (using "global_getvar") and update the status of the line to be used (using "global_setvar") * Bridge to the line returned by the script * Execute another Lua script on hang-up, which updates the global variables I am now wondering if I would run into issues in cases where I receive concurrent calls (I am using a Sangoma E1 card, and will receive multiple concurrent calls soon)? Would I need to be applying some kind of explicit mutex protection in these scripts for the global variables? Thanks in advance! With regards, Sirish
Sounds like you want to take a look into mod_fifo. William King Senior Engineer Quentus Technologies, INC 1037 NE 65th St Suite 273 Seattle, WA 98115 Main: (877) 211-9337 Office: (206) 388-4772 Cell: (253) 686-5518 william.king@quentustech.com On 12/16/2012 03:31 PM, Sirish Masur Mohan wrote:
Hello All,
I am a newbie to FreeSWITCH, please excuse if this question has already been answered.
My requirement is as follows:
· When an incoming call is received, it needs to be bridged to one of the 4 available destination lines
· Minimal management of these lines is required: need to keep track of when each line was used, so that, when a new incoming call is received, I can use the oldest used available line to bridge the call to
In order to achieve this, I have:
· Defined a few global variables in vars.xml, which would keep track of each line’s status (available/busy) and last used timestamp
· Implemented a Lua script which ‘chooses’ the line based on global variables status and timestamp (using "global_getvar") and update the status of the line to be used (using "global_setvar")
· Bridge to the line returned by the script
· Execute another Lua script on hang-up, which updates the global variables
I am now wondering if I would run into issues in cases where I receive concurrent calls (I am using a Sangoma E1 card, and will receive multiple concurrent calls soon)? Would I need to be applying some kind of explicit mutex protection in these scripts for the global variables?
Thanks in advance!
With regards,
Sirish
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Hi William, Thanks for the reply. My setup is as follows: Client(Caller)->dialup modem->PBX->FreeSWITCH->PBX-> 4 dialup modems->Server(Receiver) I basically need FreeSWITCH to bridge the incoming call to the best external destination (out of the 4 available), so that the modem training, connection etc can take place smoothly, before exchange of data. I am not sure if mod_fifo would help me in this scenario, as, I would require an agent to dial in and read the fifo. Could you please clarify? Thanks! With regards, Sirish -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of William King Sent: Monday, 17 December 2012 10:47 AM To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Sounds like you want to take a look into mod_fifo. William King Senior Engineer Quentus Technologies, INC 1037 NE 65th St Suite 273 Seattle, WA 98115 Main: (877) 211-9337 Office: (206) 388-4772 Cell: (253) 686-5518 william.king@quentustech.com
You don't have to have actual human agents for mod_fifo. You could define a user for each modem and then manually "log in" those "agents" on the command line using the fifo_member API command. Something like this: fifo_member add fifo_name {fifo_member_wait=nowait}user/1234 Where 1234 is the user id of one of the modems. You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions. Having modems go through a VoIP system sounds a bit scary. What application are you building? -MC On Sun, Dec 16, 2012 at 5:41 PM, Sirish Masur Mohan < Sirish.MasurMohan@oa.com.au> wrote:
Hi William,
Thanks for the reply.
My setup is as follows: Client(Caller)->dialup modem->PBX->FreeSWITCH->PBX-> 4 dialup modems->Server(Receiver)
I basically need FreeSWITCH to bridge the incoming call to the best external destination (out of the 4 available), so that the modem training, connection etc can take place smoothly, before exchange of data. I am not sure if mod_fifo would help me in this scenario, as, I would require an agent to dial in and read the fifo. Could you please clarify?
Thanks!
With regards, Sirish
-----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto: freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of William King Sent: Monday, 17 December 2012 10:47 AM To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?
Sounds like you want to take a look into mod_fifo.
William King Senior Engineer Quentus Technologies, INC 1037 NE 65th St Suite 273 Seattle, WA 98115 Main: (877) 211-9337 Office: (206) 388-4772 Cell: (253) 686-5518 william.king@quentustech.com
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
Hi Michael, Thanks for the reply.
You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions I am seen SIP clients such as X-Lite sending out the SIP registrations, but could you please clarify as to how this can be achieved in the PBX? The final production environment would be out in the customer's PBX, which I may not have complete control of..
What application are you building? I may not be able to provide the details because of the NDA with customer, but what I am trying to achieve is, to replace an existing IVR with FreeSWITCH in an old existing setup of the customer - that's the reason why we continue working with dialup modems!
With regards, Sirish From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Collins Sent: Tuesday, 18 December 2012 6:23 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? You don't have to have actual human agents for mod_fifo. You could define a user for each modem and then manually "log in" those "agents" on the command line using the fifo_member API command. Something like this: fifo_member add fifo_name {fifo_member_wait=nowait}user/1234 Where 1234 is the user id of one of the modems. You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions. Having modems go through a VoIP system sounds a bit scary. What application are you building? -MC On Sun, Dec 16, 2012 at 5:41 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au<mailto:Sirish.MasurMohan@oa.com.au>> wrote: Hi William, Thanks for the reply. My setup is as follows: Client(Caller)->dialup modem->PBX->FreeSWITCH->PBX-> 4 dialup modems->Server(Receiver) I basically need FreeSWITCH to bridge the incoming call to the best external destination (out of the 4 available), so that the modem training, connection etc can take place smoothly, before exchange of data. I am not sure if mod_fifo would help me in this scenario, as, I would require an agent to dial in and read the fifo. Could you please clarify? Thanks! With regards, Sirish -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org>] On Behalf Of William King Sent: Monday, 17 December 2012 10:47 AM To: freeswitch-users@lists.freeswitch.org<mailto:freeswitch-users@lists.freeswitch.org> Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Sounds like you want to take a look into mod_fifo. William King Senior Engineer Quentus Technologies, INC 1037 NE 65th St Suite 273 Seattle, WA 98115 Main: (877) 211-9337<tel:%28877%29%20211-9337> Office: (206) 388-4772<tel:%28206%29%20388-4772> Cell: (253) 686-5518<tel:%28253%29%20686-5518> william.king@quentustech.com<mailto:william.king@quentustech.com> _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org -- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
Hey Guys, Would really appreciate if you could help me out here - isn't there a way to handle concurrent calls in the dial plan, especially when Lua scripts, accessing global variables, are executed on receiving calls? Is mod_fifo the closest I could get to handle concurrency (as Michael has explained)? If yes, how do I trigger SIP registrations, especially working with a PBX which I don't have full control of? With regards, Sirish From: Sirish Masur Mohan Sent: Tuesday, 18 December 2012 1:02 PM To: FreeSWITCH Users Help Subject: RE: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Hi Michael, Thanks for the reply.
You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions I am seen SIP clients such as X-Lite sending out the SIP registrations, but could you please clarify as to how this can be achieved in the PBX? The final production environment would be out in the customer's PBX, which I may not have complete control of..
What application are you building? I may not be able to provide the details because of the NDA with customer, but what I am trying to achieve is, to replace an existing IVR with FreeSWITCH in an old existing setup of the customer - that's the reason why we continue working with dialup modems!
With regards, Sirish From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Collins Sent: Tuesday, 18 December 2012 6:23 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? You don't have to have actual human agents for mod_fifo. You could define a user for each modem and then manually "log in" those "agents" on the command line using the fifo_member API command. Something like this: fifo_member add fifo_name {fifo_member_wait=nowait}user/1234 Where 1234 is the user id of one of the modems. You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions. Having modems go through a VoIP system sounds a bit scary. What application are you building? -MC On Sun, Dec 16, 2012 at 5:41 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au<mailto:Sirish.MasurMohan@oa.com.au>> wrote: Hi William, Thanks for the reply. My setup is as follows: Client(Caller)->dialup modem->PBX->FreeSWITCH->PBX-> 4 dialup modems->Server(Receiver) I basically need FreeSWITCH to bridge the incoming call to the best external destination (out of the 4 available), so that the modem training, connection etc can take place smoothly, before exchange of data. I am not sure if mod_fifo would help me in this scenario, as, I would require an agent to dial in and read the fifo. Could you please clarify? Thanks! With regards, Sirish -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org>] On Behalf Of William King Sent: Monday, 17 December 2012 10:47 AM To: freeswitch-users@lists.freeswitch.org<mailto:freeswitch-users@lists.freeswitch.org> Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Sounds like you want to take a look into mod_fifo. William King Senior Engineer Quentus Technologies, INC 1037 NE 65th St Suite 273 Seattle, WA 98115 Main: (877) 211-9337<tel:%28877%29%20211-9337> Office: (206) 388-4772<tel:%28206%29%20388-4772> Cell: (253) 686-5518<tel:%28253%29%20686-5518> william.king@quentustech.com<mailto:william.king@quentustech.com> _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org -- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
To trigger SIP registrations you'd need the PBX to have a SIP client. I'm assuming this is possible, but maybe that's a false assumption. How are you physically connecting from FreeSWITCH to the PBX? -MC On Tue, Dec 18, 2012 at 2:36 PM, Sirish Masur Mohan < Sirish.MasurMohan@oa.com.au> wrote:
Hey Guys,****
** **
Would really appreciate if you could help me out here – isn’t there a way to handle concurrent calls in the dial plan, especially when Lua scripts, accessing global variables, are executed on receiving calls? ****
** **
Is mod_fifo the closest I could get to handle concurrency (as Michael has explained)? If yes, how do I trigger SIP registrations, especially working with a PBX which I don’t have full control of?****
** **
With regards,****
Sirish****
** **
*From:* Sirish Masur Mohan *Sent:* Tuesday, 18 December 2012 1:02 PM *To:* FreeSWITCH Users Help *Subject:* RE: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?****
** **
Hi Michael,****
** **
Thanks for the reply. ****
** **
You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions****
I am seen SIP clients such as X-Lite sending out the SIP registrations, but could you please clarify as to how this can be achieved in the PBX? The final production environment would be out in the customer’s PBX, which I may not have complete control of.. ****
** **
What application are you building?****
I may not be able to provide the details because of the NDA with customer, but what I am trying to achieve is, to replace an existing IVR with FreeSWITCH in an old existing setup of the customer – that’s the reason why we continue working with dialup modems!****
** **
With regards,****
Sirish****
** **
*From:* freeswitch-users-bounces@lists.freeswitch.org [ mailto:freeswitch-users-bounces@lists.freeswitch.org<freeswitch-users-bounces@lists.freeswitch.org>] *On Behalf Of *Michael Collins *Sent:* Tuesday, 18 December 2012 6:23 AM *To:* FreeSWITCH Users Help *Subject:* Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?****
** **
You don't have to have actual human agents for mod_fifo. You could define a user for each modem and then manually "log in" those "agents" on the command line using the fifo_member API command. Something like this:
fifo_member add fifo_name {fifo_member_wait=nowait}user/1234
Where 1234 is the user id of one of the modems. You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions.
Having modems go through a VoIP system sounds a bit scary. What application are you building? -MC****
On Sun, Dec 16, 2012 at 5:41 PM, Sirish Masur Mohan < Sirish.MasurMohan@oa.com.au> wrote:****
Hi William,
Thanks for the reply.
My setup is as follows: Client(Caller)->dialup modem->PBX->FreeSWITCH->PBX-> 4 dialup modems->Server(Receiver)
I basically need FreeSWITCH to bridge the incoming call to the best external destination (out of the 4 available), so that the modem training, connection etc can take place smoothly, before exchange of data. I am not sure if mod_fifo would help me in this scenario, as, I would require an agent to dial in and read the fifo. Could you please clarify?
Thanks!
With regards, Sirish****
-----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto: freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of William King Sent: Monday, 17 December 2012 10:47 AM To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?
Sounds like you want to take a look into mod_fifo.
William King Senior Engineer Quentus Technologies, INC 1037 NE 65th St Suite 273 Seattle, WA 98115 Main: (877) 211-9337 Office: (206) 388-4772 Cell: (253) 686-5518 william.king@quentustech.com
****
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org****
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org****
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
Hi Michael,
How are you physically connecting from FreeSWITCH to the PBX?
I connect this via E1 link - I have a Sangoma card installed on the FreeSWITCH machine. With regards, Sirish From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Collins Sent: Wednesday, 19 December 2012 1:31 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? To trigger SIP registrations you'd need the PBX to have a SIP client. I'm assuming this is possible, but maybe that's a false assumption. How are you physically connecting from FreeSWITCH to the PBX? -MC On Tue, Dec 18, 2012 at 2:36 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au<mailto:Sirish.MasurMohan@oa.com.au>> wrote: Hey Guys, Would really appreciate if you could help me out here - isn't there a way to handle concurrent calls in the dial plan, especially when Lua scripts, accessing global variables, are executed on receiving calls? Is mod_fifo the closest I could get to handle concurrency (as Michael has explained)? If yes, how do I trigger SIP registrations, especially working with a PBX which I don't have full control of? With regards, Sirish From: Sirish Masur Mohan Sent: Tuesday, 18 December 2012 1:02 PM To: FreeSWITCH Users Help Subject: RE: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Hi Michael, Thanks for the reply.
You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions I am seen SIP clients such as X-Lite sending out the SIP registrations, but could you please clarify as to how this can be achieved in the PBX? The final production environment would be out in the customer's PBX, which I may not have complete control of..
What application are you building? I may not be able to provide the details because of the NDA with customer, but what I am trying to achieve is, to replace an existing IVR with FreeSWITCH in an old existing setup of the customer - that's the reason why we continue working with dialup modems!
With regards, Sirish From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Collins Sent: Tuesday, 18 December 2012 6:23 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? You don't have to have actual human agents for mod_fifo. You could define a user for each modem and then manually "log in" those "agents" on the command line using the fifo_member API command. Something like this: fifo_member add fifo_name {fifo_member_wait=nowait}user/1234 Where 1234 is the user id of one of the modems. You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions. Having modems go through a VoIP system sounds a bit scary. What application are you building? -MC On Sun, Dec 16, 2012 at 5:41 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au<mailto:Sirish.MasurMohan@oa.com.au>> wrote: Hi William, Thanks for the reply. My setup is as follows: Client(Caller)->dialup modem->PBX->FreeSWITCH->PBX-> 4 dialup modems->Server(Receiver) I basically need FreeSWITCH to bridge the incoming call to the best external destination (out of the 4 available), so that the modem training, connection etc can take place smoothly, before exchange of data. I am not sure if mod_fifo would help me in this scenario, as, I would require an agent to dial in and read the fifo. Could you please clarify? Thanks! With regards, Sirish -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org>] On Behalf Of William King Sent: Monday, 17 December 2012 10:47 AM To: freeswitch-users@lists.freeswitch.org<mailto:freeswitch-users@lists.freeswitch.org> Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Sounds like you want to take a look into mod_fifo. William King Senior Engineer Quentus Technologies, INC 1037 NE 65th St Suite 273 Seattle, WA 98115 Main: (877) 211-9337<tel:%28877%29%20211-9337> Office: (206) 388-4772<tel:%28206%29%20388-4772> Cell: (253) 686-5518<tel:%28253%29%20686-5518> william.king@quentustech.com<mailto:william.king@quentustech.com> _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org -- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org -- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
Sirish, Since you're using an E1 to connect to the PBX then really all you need to do is keep track of the last time each port was hung up and whether or not a given port is currently in use. I would use api_on_answer to launch a simple script to set a flag to say that a particular port is in use and then use the api_hangup_hook to launch another script when the call ends. The channel variables page on the wiki has some examples of how to use these. I recommend that you write simple Lua scripts that use the "hash" API to store information in the local database. Also, check out the "hash_dump" API as it is a useful way to quickly see what all is stored there. For an example of how to add, remove, and read information from the local database using the "hash" API please see conf/dialplan/default.xml. Search for "hash" and you'll see all sorts of examples of how the example dialplan uses the local database to store useful information that allows us to implement features like call return, call intercept, etc. -MC On Tue, Dec 18, 2012 at 7:39 PM, Sirish Masur Mohan < Sirish.MasurMohan@oa.com.au> wrote:
Hi Michael,****
** **
How are you physically connecting from FreeSWITCH to the PBX?****
** **
I connect this via E1 link – I have a Sangoma card installed on the FreeSWITCH machine.****
** **
With regards,****
Sirish****
** **
*From:* freeswitch-users-bounces@lists.freeswitch.org [mailto: freeswitch-users-bounces@lists.freeswitch.org] *On Behalf Of *Michael Collins *Sent:* Wednesday, 19 December 2012 1:31 PM *To:* FreeSWITCH Users Help *Subject:* Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?****
** **
To trigger SIP registrations you'd need the PBX to have a SIP client. I'm assuming this is possible, but maybe that's a false assumption. How are you physically connecting from FreeSWITCH to the PBX?
-MC****
On Tue, Dec 18, 2012 at 2:36 PM, Sirish Masur Mohan < Sirish.MasurMohan@oa.com.au> wrote:****
Hey Guys,****
****
Would really appreciate if you could help me out here – isn’t there a way to handle concurrent calls in the dial plan, especially when Lua scripts, accessing global variables, are executed on receiving calls? ****
****
Is mod_fifo the closest I could get to handle concurrency (as Michael has explained)? If yes, how do I trigger SIP registrations, especially working with a PBX which I don’t have full control of?****
****
With regards,****
Sirish****
****
*From:* Sirish Masur Mohan *Sent:* Tuesday, 18 December 2012 1:02 PM *To:* FreeSWITCH Users Help *Subject:* RE: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?****
****
Hi Michael,****
****
Thanks for the reply. ****
****
You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions****
I am seen SIP clients such as X-Lite sending out the SIP registrations, but could you please clarify as to how this can be achieved in the PBX? The final production environment would be out in the customer’s PBX, which I may not have complete control of.. ****
****
What application are you building?****
I may not be able to provide the details because of the NDA with customer, but what I am trying to achieve is, to replace an existing IVR with FreeSWITCH in an old existing setup of the customer – that’s the reason why we continue working with dialup modems!****
****
With regards,****
Sirish****
****
*From:* freeswitch-users-bounces@lists.freeswitch.org [ mailto:freeswitch-users-bounces@lists.freeswitch.org<freeswitch-users-bounces@lists.freeswitch.org>] *On Behalf Of *Michael Collins *Sent:* Tuesday, 18 December 2012 6:23 AM *To:* FreeSWITCH Users Help *Subject:* Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?****
****
You don't have to have actual human agents for mod_fifo. You could define a user for each modem and then manually "log in" those "agents" on the command line using the fifo_member API command. Something like this:
fifo_member add fifo_name {fifo_member_wait=nowait}user/1234
Where 1234 is the user id of one of the modems. You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions.
Having modems go through a VoIP system sounds a bit scary. What application are you building? -MC****
On Sun, Dec 16, 2012 at 5:41 PM, Sirish Masur Mohan < Sirish.MasurMohan@oa.com.au> wrote:****
Hi William,
Thanks for the reply.
My setup is as follows: Client(Caller)->dialup modem->PBX->FreeSWITCH->PBX-> 4 dialup modems->Server(Receiver)
I basically need FreeSWITCH to bridge the incoming call to the best external destination (out of the 4 available), so that the modem training, connection etc can take place smoothly, before exchange of data. I am not sure if mod_fifo would help me in this scenario, as, I would require an agent to dial in and read the fifo. Could you please clarify?
Thanks!
With regards, Sirish****
-----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto: freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of William King Sent: Monday, 17 December 2012 10:47 AM To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?
Sounds like you want to take a look into mod_fifo.
William King Senior Engineer Quentus Technologies, INC 1037 NE 65th St Suite 273 Seattle, WA 98115 Main: (877) 211-9337 Office: (206) 388-4772 Cell: (253) 686-5518 william.king@quentustech.com****
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org****
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org****
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org****
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
****
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
Hi Michael, Thanks for the reply, and the suggestions. My current implementation is a similar to what you have suggested, i.e.: 1. I have defined 4 sets of global variables in vars.xml, where each set keeps a track of port's status and last used timestamp 2. In the dialplan, I execute a simple Lua script which 'chooses' the line based on global variables status and timestamp (using "global_getvar") and update the status of the line to be used (using "global_setvar") 3. Bridge to the line returned by the above script 4. Execute another Lua script on hang-up, which updates the global variables (status and timestamp) If I were to implement the hash way, I would have to probably do the following: 1. In the dialplan, I execute a simple Lua script which 'chooses' the line by reading the hash values of the line status and timestamp and update the hash status of the line to be used 2. Bridge to the line returned by the above script 3. Execute another Lua script on hang-up, which updates the hash values (status and timestamp) But I am still not clear on the concurrency question - if FreeSWITCH has received 2 calls at the same time on the E1 line, should I be worried about protecting the script that gets executed to access the hash, decide on the line to be used, and then update the hash? Thanks again! With regards, Sirish From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Collins Sent: Friday, 21 December 2012 3:42 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Sirish, Since you're using an E1 to connect to the PBX then really all you need to do is keep track of the last time each port was hung up and whether or not a given port is currently in use. I would use api_on_answer to launch a simple script to set a flag to say that a particular port is in use and then use the api_hangup_hook to launch another script when the call ends. The channel variables page on the wiki has some examples of how to use these. I recommend that you write simple Lua scripts that use the "hash" API to store information in the local database. Also, check out the "hash_dump" API as it is a useful way to quickly see what all is stored there. For an example of how to add, remove, and read information from the local database using the "hash" API please see conf/dialplan/default.xml. Search for "hash" and you'll see all sorts of examples of how the example dialplan uses the local database to store useful information that allows us to implement features like call return, call intercept, etc. -MC On Tue, Dec 18, 2012 at 7:39 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au<mailto:Sirish.MasurMohan@oa.com.au>> wrote: Hi Michael,
How are you physically connecting from FreeSWITCH to the PBX?
I connect this via E1 link - I have a Sangoma card installed on the FreeSWITCH machine. With regards, Sirish From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org>] On Behalf Of Michael Collins Sent: Wednesday, 19 December 2012 1:31 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? To trigger SIP registrations you'd need the PBX to have a SIP client. I'm assuming this is possible, but maybe that's a false assumption. How are you physically connecting from FreeSWITCH to the PBX? -MC On Tue, Dec 18, 2012 at 2:36 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au<mailto:Sirish.MasurMohan@oa.com.au>> wrote: Hey Guys, Would really appreciate if you could help me out here - isn't there a way to handle concurrent calls in the dial plan, especially when Lua scripts, accessing global variables, are executed on receiving calls? Is mod_fifo the closest I could get to handle concurrency (as Michael has explained)? If yes, how do I trigger SIP registrations, especially working with a PBX which I don't have full control of? With regards, Sirish From: Sirish Masur Mohan Sent: Tuesday, 18 December 2012 1:02 PM To: FreeSWITCH Users Help Subject: RE: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Hi Michael, Thanks for the reply.
You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions I am seen SIP clients such as X-Lite sending out the SIP registrations, but could you please clarify as to how this can be achieved in the PBX? The final production environment would be out in the customer's PBX, which I may not have complete control of..
What application are you building? I may not be able to provide the details because of the NDA with customer, but what I am trying to achieve is, to replace an existing IVR with FreeSWITCH in an old existing setup of the customer - that's the reason why we continue working with dialup modems!
With regards, Sirish From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Collins Sent: Tuesday, 18 December 2012 6:23 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? You don't have to have actual human agents for mod_fifo. You could define a user for each modem and then manually "log in" those "agents" on the command line using the fifo_member API command. Something like this: fifo_member add fifo_name {fifo_member_wait=nowait}user/1234 Where 1234 is the user id of one of the modems. You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions. Having modems go through a VoIP system sounds a bit scary. What application are you building? -MC On Sun, Dec 16, 2012 at 5:41 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au<mailto:Sirish.MasurMohan@oa.com.au>> wrote: Hi William, Thanks for the reply. My setup is as follows: Client(Caller)->dialup modem->PBX->FreeSWITCH->PBX-> 4 dialup modems->Server(Receiver) I basically need FreeSWITCH to bridge the incoming call to the best external destination (out of the 4 available), so that the modem training, connection etc can take place smoothly, before exchange of data. I am not sure if mod_fifo would help me in this scenario, as, I would require an agent to dial in and read the fifo. Could you please clarify? Thanks! With regards, Sirish -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org>] On Behalf Of William King Sent: Monday, 17 December 2012 10:47 AM To: freeswitch-users@lists.freeswitch.org<mailto:freeswitch-users@lists.freeswitch.org> Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Sounds like you want to take a look into mod_fifo. William King Senior Engineer Quentus Technologies, INC 1037 NE 65th St Suite 273 Seattle, WA 98115 Main: (877) 211-9337<tel:%28877%29%20211-9337> Office: (206) 388-4772<tel:%28206%29%20388-4772> Cell: (253) 686-5518<tel:%28253%29%20686-5518> william.king@quentustech.com<mailto:william.king@quentustech.com> _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org -- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org -- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org -- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
If I remember correctly when when anthm added the option by request, global_setvar is NOT safe for setting concurrently. Very occasionally should be ok for config changes without a restart, but it is not safe to use from call dial plans where calls are running alongside each other. You should look at using mod_hash or mod_db, which are much safer Sent from my iPad On 20 Dec 2012, at 23:23, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au> wrote:
Hi Michael,
Thanks for the reply, and the suggestions.
My current implementation is a similar to what you have suggested, i.e.: 1. I have defined 4 sets of global variables in vars.xml, where each set keeps a track of port’s status and last used timestamp 2. In the dialplan, I execute a simple Lua script which ‘chooses’ the line based on global variables status and timestamp (using "global_getvar") and update the status of the line to be used (using "global_setvar") 3. Bridge to the line returned by the above script 4. Execute another Lua script on hang-up, which updates the global variables (status and timestamp)
If I were to implement the hash way, I would have to probably do the following: 1. In the dialplan, I execute a simple Lua script which ‘chooses’ the line by reading the hash values of the line status and timestamp and update the hash status of the line to be used 2. Bridge to the line returned by the above script 3. Execute another Lua script on hang-up, which updates the hash values (status and timestamp)
But I am still not clear on the concurrency question – if FreeSWITCH has received 2 calls at the same time on the E1 line, should I be worried about protecting the script that gets executed to access the hash, decide on the line to be used, and then update the hash?
Thanks again!
With regards, Sirish
From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Collins Sent: Friday, 21 December 2012 3:42 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?
Sirish,
Since you're using an E1 to connect to the PBX then really all you need to do is keep track of the last time each port was hung up and whether or not a given port is currently in use. I would use api_on_answer to launch a simple script to set a flag to say that a particular port is in use and then use the api_hangup_hook to launch another script when the call ends.
The channel variables page on the wiki has some examples of how to use these. I recommend that you write simple Lua scripts that use the "hash" API to store information in the local database. Also, check out the "hash_dump" API as it is a useful way to quickly see what all is stored there.
For an example of how to add, remove, and read information from the local database using the "hash" API please see conf/dialplan/default.xml. Search for "hash" and you'll see all sorts of examples of how the example dialplan uses the local database to store useful information that allows us to implement features like call return, call intercept, etc.
-MC
On Tue, Dec 18, 2012 at 7:39 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au> wrote: Hi Michael,
How are you physically connecting from FreeSWITCH to the PBX?
I connect this via E1 link – I have a Sangoma card installed on the FreeSWITCH machine.
With regards, Sirish
From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Collins Sent: Wednesday, 19 December 2012 1:31 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?
To trigger SIP registrations you'd need the PBX to have a SIP client. I'm assuming this is possible, but maybe that's a false assumption. How are you physically connecting from FreeSWITCH to the PBX?
-MC
On Tue, Dec 18, 2012 at 2:36 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au> wrote: Hey Guys,
Would really appreciate if you could help me out here – isn’t there a way to handle concurrent calls in the dial plan, especially when Lua scripts, accessing global variables, are executed on receiving calls?
Is mod_fifo the closest I could get to handle concurrency (as Michael has explained)? If yes, how do I trigger SIP registrations, especially working with a PBX which I don’t have full control of?
With regards, Sirish
From: Sirish Masur Mohan Sent: Tuesday, 18 December 2012 1:02 PM To: FreeSWITCH Users Help Subject: RE: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?
Hi Michael,
Thanks for the reply.
You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions I am seen SIP clients such as X-Lite sending out the SIP registrations, but could you please clarify as to how this can be achieved in the PBX? The final production environment would be out in the customer’s PBX, which I may not have complete control of..
What application are you building? I may not be able to provide the details because of the NDA with customer, but what I am trying to achieve is, to replace an existing IVR with FreeSWITCH in an old existing setup of the customer – that’s the reason why we continue working with dialup modems!
With regards, Sirish
From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Collins Sent: Tuesday, 18 December 2012 6:23 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?
You don't have to have actual human agents for mod_fifo. You could define a user for each modem and then manually "log in" those "agents" on the command line using the fifo_member API command. Something like this:
fifo_member add fifo_name {fifo_member_wait=nowait}user/1234
Where 1234 is the user id of one of the modems. You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions.
Having modems go through a VoIP system sounds a bit scary. What application are you building? -MC
On Sun, Dec 16, 2012 at 5:41 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au> wrote: Hi William,
Thanks for the reply.
My setup is as follows: Client(Caller)->dialup modem->PBX->FreeSWITCH->PBX-> 4 dialup modems->Server(Receiver)
I basically need FreeSWITCH to bridge the incoming call to the best external destination (out of the 4 available), so that the modem training, connection etc can take place smoothly, before exchange of data. I am not sure if mod_fifo would help me in this scenario, as, I would require an agent to dial in and read the fifo. Could you please clarify?
Thanks!
With regards, Sirish
-----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of William King Sent: Monday, 17 December 2012 10:47 AM To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?
Sounds like you want to take a look into mod_fifo.
William King Senior Engineer Quentus Technologies, INC 1037 NE 65th St Suite 273 Seattle, WA 98115 Main: (877) 211-9337 Office: (206) 388-4772 Cell: (253) 686-5518 william.king@quentustech.com
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
Thanks Steven, noted! With regards, Sirish From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Steven Ayre Sent: Friday, 21 December 2012 1:33 PM To: FreeSWITCH Users Help Cc: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? If I remember correctly when when anthm added the option by request, global_setvar is NOT safe for setting concurrently. Very occasionally should be ok for config changes without a restart, but it is not safe to use from call dial plans where calls are running alongside each other. You should look at using mod_hash or mod_db, which are much safer Sent from my iPad On 20 Dec 2012, at 23:23, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au<mailto:Sirish.MasurMohan@oa.com.au>> wrote: Hi Michael, Thanks for the reply, and the suggestions. My current implementation is a similar to what you have suggested, i.e.: 1. I have defined 4 sets of global variables in vars.xml, where each set keeps a track of port’s status and last used timestamp 2. In the dialplan, I execute a simple Lua script which ‘chooses’ the line based on global variables status and timestamp (using "global_getvar") and update the status of the line to be used (using "global_setvar") 3. Bridge to the line returned by the above script 4. Execute another Lua script on hang-up, which updates the global variables (status and timestamp) If I were to implement the hash way, I would have to probably do the following: 1. In the dialplan, I execute a simple Lua script which ‘chooses’ the line by reading the hash values of the line status and timestamp and update the hash status of the line to be used 2. Bridge to the line returned by the above script 3. Execute another Lua script on hang-up, which updates the hash values (status and timestamp) But I am still not clear on the concurrency question – if FreeSWITCH has received 2 calls at the same time on the E1 line, should I be worried about protecting the script that gets executed to access the hash, decide on the line to be used, and then update the hash? Thanks again! With regards, Sirish From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Collins Sent: Friday, 21 December 2012 3:42 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Sirish, Since you're using an E1 to connect to the PBX then really all you need to do is keep track of the last time each port was hung up and whether or not a given port is currently in use. I would use api_on_answer to launch a simple script to set a flag to say that a particular port is in use and then use the api_hangup_hook to launch another script when the call ends. The channel variables page on the wiki has some examples of how to use these. I recommend that you write simple Lua scripts that use the "hash" API to store information in the local database. Also, check out the "hash_dump" API as it is a useful way to quickly see what all is stored there. For an example of how to add, remove, and read information from the local database using the "hash" API please see conf/dialplan/default.xml. Search for "hash" and you'll see all sorts of examples of how the example dialplan uses the local database to store useful information that allows us to implement features like call return, call intercept, etc. -MC On Tue, Dec 18, 2012 at 7:39 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au<mailto:Sirish.MasurMohan@oa.com.au>> wrote: Hi Michael,
How are you physically connecting from FreeSWITCH to the PBX?
I connect this via E1 link – I have a Sangoma card installed on the FreeSWITCH machine. With regards, Sirish From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org>] On Behalf Of Michael Collins Sent: Wednesday, 19 December 2012 1:31 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? To trigger SIP registrations you'd need the PBX to have a SIP client. I'm assuming this is possible, but maybe that's a false assumption. How are you physically connecting from FreeSWITCH to the PBX? -MC On Tue, Dec 18, 2012 at 2:36 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au<mailto:Sirish.MasurMohan@oa.com.au>> wrote: Hey Guys, Would really appreciate if you could help me out here – isn’t there a way to handle concurrent calls in the dial plan, especially when Lua scripts, accessing global variables, are executed on receiving calls? Is mod_fifo the closest I could get to handle concurrency (as Michael has explained)? If yes, how do I trigger SIP registrations, especially working with a PBX which I don’t have full control of? With regards, Sirish From: Sirish Masur Mohan Sent: Tuesday, 18 December 2012 1:02 PM To: FreeSWITCH Users Help Subject: RE: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Hi Michael, Thanks for the reply.
You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions I am seen SIP clients such as X-Lite sending out the SIP registrations, but could you please clarify as to how this can be achieved in the PBX? The final production environment would be out in the customer’s PBX, which I may not have complete control of..
What application are you building? I may not be able to provide the details because of the NDA with customer, but what I am trying to achieve is, to replace an existing IVR with FreeSWITCH in an old existing setup of the customer – that’s the reason why we continue working with dialup modems!
With regards, Sirish From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Collins Sent: Tuesday, 18 December 2012 6:23 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? You don't have to have actual human agents for mod_fifo. You could define a user for each modem and then manually "log in" those "agents" on the command line using the fifo_member API command. Something like this: fifo_member add fifo_name {fifo_member_wait=nowait}user/1234 Where 1234 is the user id of one of the modems. You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions. Having modems go through a VoIP system sounds a bit scary. What application are you building? -MC On Sun, Dec 16, 2012 at 5:41 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au<mailto:Sirish.MasurMohan@oa.com.au>> wrote: Hi William, Thanks for the reply. My setup is as follows: Client(Caller)->dialup modem->PBX->FreeSWITCH->PBX-> 4 dialup modems->Server(Receiver) I basically need FreeSWITCH to bridge the incoming call to the best external destination (out of the 4 available), so that the modem training, connection etc can take place smoothly, before exchange of data. I am not sure if mod_fifo would help me in this scenario, as, I would require an agent to dial in and read the fifo. Could you please clarify? Thanks! With regards, Sirish -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org>] On Behalf Of William King Sent: Monday, 17 December 2012 10:47 AM To: freeswitch-users@lists.freeswitch.org<mailto:freeswitch-users@lists.freeswitch.org> Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Sounds like you want to take a look into mod_fifo. William King Senior Engineer Quentus Technologies, INC 1037 NE 65th St Suite 273 Seattle, WA 98115 Main: (877) 211-9337<tel:%28877%29%20211-9337> Office: (206) 388-4772<tel:%28206%29%20388-4772> Cell: (253) 686-5518<tel:%28253%29%20686-5518> william.king@quentustech.com<mailto:william.king@quentustech.com> _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org -- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org -- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org -- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<http://lists.freeswitch.org/mailman/options/freeswitch-users> http://www.freeswitch.org
Agreed, the hash/db options are safe and effective. You don't need global variables. I highly recommend that you look at the default.xml dialplan file and look at the places where "hash" occurs. In Local_Extension a lot of items are written to the local database with hash "inserts" and elsewhere you'll see hash "selects" and the occasional hash "delete". Use the hash_dump command to see what's in the database. Make a few test calls and do a hash_dump before, during, and after the call. You'll quickly see what you can do with the hash command and storing information. Just store information for each of your ports and use a Lua script to read and/or write as needed. -MC On Thu, Dec 20, 2012 at 6:32 PM, Steven Ayre <steveayre@gmail.com> wrote:
If I remember correctly when when anthm added the option by request, global_setvar is NOT safe for setting concurrently. Very occasionally should be ok for config changes without a restart, but it is not safe to use from call dial plans where calls are running alongside each other.
You should look at using mod_hash or mod_db, which are much safer
Sent from my iPad
On 20 Dec 2012, at 23:23, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au> wrote:
Hi Michael,****
** **
Thanks for the reply, and the suggestions.****
** **
My current implementation is a similar to what you have suggested, i.e.:** **
1. I have defined 4 sets of global variables in vars.xml, where each set keeps a track of port’s status and last used timestamp****
2. In the dialplan, I execute a simple Lua script which ‘chooses’ the line based on global variables status and timestamp (using "global_getvar") and update the status of the line to be used (using "global_setvar")****
3. Bridge to the line returned by the above script****
4. Execute another Lua script on hang-up, which updates the global variables (status and timestamp)****
** **
If I were to implement the hash way, I would have to probably do the following:****
1. In the dialplan, I execute a simple Lua script which ‘chooses’ the line by reading the hash values of the line status and timestamp and update the hash status of the line to be used ****
2. Bridge to the line returned by the above script****
3. Execute another Lua script on hang-up, which updates the hash values (status and timestamp)****
** **
But I am still not clear on the concurrency question – if FreeSWITCH has received 2 calls at the same time on the E1 line, should I be worried about protecting the script that gets executed to access the hash, decide on the line to be used, and then update the hash?****
** **
Thanks again!****
** **
With regards,****
Sirish****
** **
*From:* freeswitch-users-bounces@lists.freeswitch.org [ mailto:freeswitch-users-bounces@lists.freeswitch.org<freeswitch-users-bounces@lists.freeswitch.org>] *On Behalf Of *Michael Collins *Sent:* Friday, 21 December 2012 3:42 AM *To:* FreeSWITCH Users Help *Subject:* Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?****
** **
Sirish,
Since you're using an E1 to connect to the PBX then really all you need to do is keep track of the last time each port was hung up and whether or not a given port is currently in use. I would use api_on_answer to launch a simple script to set a flag to say that a particular port is in use and then use the api_hangup_hook to launch another script when the call ends.
The channel variables page on the wiki has some examples of how to use these. I recommend that you write simple Lua scripts that use the "hash" API to store information in the local database. Also, check out the "hash_dump" API as it is a useful way to quickly see what all is stored there.
For an example of how to add, remove, and read information from the local database using the "hash" API please see conf/dialplan/default.xml. Search for "hash" and you'll see all sorts of examples of how the example dialplan uses the local database to store useful information that allows us to implement features like call return, call intercept, etc.
-MC****
On Tue, Dec 18, 2012 at 7:39 PM, Sirish Masur Mohan < Sirish.MasurMohan@oa.com.au> wrote:****
Hi Michael,****
****
How are you physically connecting from FreeSWITCH to the PBX?****
****
I connect this via E1 link – I have a Sangoma card installed on the FreeSWITCH machine.****
****
With regards,****
Sirish****
****
*From:* freeswitch-users-bounces@lists.freeswitch.org [mailto: freeswitch-users-bounces@lists.freeswitch.org] *On Behalf Of *Michael Collins *Sent:* Wednesday, 19 December 2012 1:31 PM *To:* FreeSWITCH Users Help *Subject:* Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?****
****
To trigger SIP registrations you'd need the PBX to have a SIP client. I'm assuming this is possible, but maybe that's a false assumption. How are you physically connecting from FreeSWITCH to the PBX?
-MC****
On Tue, Dec 18, 2012 at 2:36 PM, Sirish Masur Mohan < Sirish.MasurMohan@oa.com.au> wrote:****
Hey Guys,****
****
Would really appreciate if you could help me out here – isn’t there a way to handle concurrent calls in the dial plan, especially when Lua scripts, accessing global variables, are executed on receiving calls? ****
****
Is mod_fifo the closest I could get to handle concurrency (as Michael has explained)? If yes, how do I trigger SIP registrations, especially working with a PBX which I don’t have full control of?****
****
With regards,****
Sirish****
****
*From:* Sirish Masur Mohan *Sent:* Tuesday, 18 December 2012 1:02 PM *To:* FreeSWITCH Users Help *Subject:* RE: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?****
****
Hi Michael,****
****
Thanks for the reply. ****
****
You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions****
I am seen SIP clients such as X-Lite sending out the SIP registrations, but could you please clarify as to how this can be achieved in the PBX? The final production environment would be out in the customer’s PBX, which I may not have complete control of.. ****
****
What application are you building?****
I may not be able to provide the details because of the NDA with customer, but what I am trying to achieve is, to replace an existing IVR with FreeSWITCH in an old existing setup of the customer – that’s the reason why we continue working with dialup modems!****
****
With regards,****
Sirish****
****
*From:* freeswitch-users-bounces@lists.freeswitch.org [ mailto:freeswitch-users-bounces@lists.freeswitch.org<freeswitch-users-bounces@lists.freeswitch.org>] *On Behalf Of *Michael Collins *Sent:* Tuesday, 18 December 2012 6:23 AM *To:* FreeSWITCH Users Help *Subject:* Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?****
****
You don't have to have actual human agents for mod_fifo. You could define a user for each modem and then manually "log in" those "agents" on the command line using the fifo_member API command. Something like this:
fifo_member add fifo_name {fifo_member_wait=nowait}user/1234
Where 1234 is the user id of one of the modems. You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions.
Having modems go through a VoIP system sounds a bit scary. What application are you building? -MC****
On Sun, Dec 16, 2012 at 5:41 PM, Sirish Masur Mohan < Sirish.MasurMohan@oa.com.au> wrote:****
Hi William,
Thanks for the reply.
My setup is as follows: Client(Caller)->dialup modem->PBX->FreeSWITCH->PBX-> 4 dialup modems->Server(Receiver)
I basically need FreeSWITCH to bridge the incoming call to the best external destination (out of the 4 available), so that the modem training, connection etc can take place smoothly, before exchange of data. I am not sure if mod_fifo would help me in this scenario, as, I would require an agent to dial in and read the fifo. Could you please clarify?
Thanks!
With regards, Sirish****
-----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto: freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of William King Sent: Monday, 17 December 2012 10:47 AM To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled?
Sounds like you want to take a look into mod_fifo.
William King Senior Engineer Quentus Technologies, INC 1037 NE 65th St Suite 273 Seattle, WA 98115 Main: (877) 211-9337 Office: (206) 388-4772 Cell: (253) 686-5518 william.king@quentustech.com****
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org****
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org****
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org****
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org****
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org****
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
****
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@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@freeswitch.org http://www.freeswitchsolutions.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
-- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
Hi Michael, I have modified my implementation to use hash, as recommended. I now use a Lua script which will * hash selects to read the port status & previous timestamp of each port * decide on the port to be used based on the oldest time stamp - hash insert the status of this port to busy On hang-up, I have another Lua script which would hash insert the status of this port back to idle, and hash insert the latest timestamp If I were to have two or more incoming calls at the same time, and the answering Lua script were to get executed at the same time for these calls, I am still worried about the concurrency factor - wouldn't the Lua script hash select and return the same port? If yes, how do I 'protect' this script to handle concurrency? Thanks! With regards, Sirish From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Collins Sent: Saturday, 22 December 2012 4:32 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Agreed, the hash/db options are safe and effective. You don't need global variables. I highly recommend that you look at the default.xml dialplan file and look at the places where "hash" occurs. In Local_Extension a lot of items are written to the local database with hash "inserts" and elsewhere you'll see hash "selects" and the occasional hash "delete". Use the hash_dump command to see what's in the database. Make a few test calls and do a hash_dump before, during, and after the call. You'll quickly see what you can do with the hash command and storing information. Just store information for each of your ports and use a Lua script to read and/or write as needed. -MC On Thu, Dec 20, 2012 at 6:32 PM, Steven Ayre <steveayre@gmail.com<mailto:steveayre@gmail.com>> wrote: If I remember correctly when when anthm added the option by request, global_setvar is NOT safe for setting concurrently. Very occasionally should be ok for config changes without a restart, but it is not safe to use from call dial plans where calls are running alongside each other. You should look at using mod_hash or mod_db, which are much safer Sent from my iPad On 20 Dec 2012, at 23:23, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au<mailto:Sirish.MasurMohan@oa.com.au>> wrote: Hi Michael, Thanks for the reply, and the suggestions. My current implementation is a similar to what you have suggested, i.e.: 1. I have defined 4 sets of global variables in vars.xml, where each set keeps a track of port's status and last used timestamp 2. In the dialplan, I execute a simple Lua script which 'chooses' the line based on global variables status and timestamp (using "global_getvar") and update the status of the line to be used (using "global_setvar") 3. Bridge to the line returned by the above script 4. Execute another Lua script on hang-up, which updates the global variables (status and timestamp) If I were to implement the hash way, I would have to probably do the following: 1. In the dialplan, I execute a simple Lua script which 'chooses' the line by reading the hash values of the line status and timestamp and update the hash status of the line to be used 2. Bridge to the line returned by the above script 3. Execute another Lua script on hang-up, which updates the hash values (status and timestamp) But I am still not clear on the concurrency question - if FreeSWITCH has received 2 calls at the same time on the E1 line, should I be worried about protecting the script that gets executed to access the hash, decide on the line to be used, and then update the hash? Thanks again! With regards, Sirish From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Collins Sent: Friday, 21 December 2012 3:42 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Sirish, Since you're using an E1 to connect to the PBX then really all you need to do is keep track of the last time each port was hung up and whether or not a given port is currently in use. I would use api_on_answer to launch a simple script to set a flag to say that a particular port is in use and then use the api_hangup_hook to launch another script when the call ends. The channel variables page on the wiki has some examples of how to use these. I recommend that you write simple Lua scripts that use the "hash" API to store information in the local database. Also, check out the "hash_dump" API as it is a useful way to quickly see what all is stored there. For an example of how to add, remove, and read information from the local database using the "hash" API please see conf/dialplan/default.xml. Search for "hash" and you'll see all sorts of examples of how the example dialplan uses the local database to store useful information that allows us to implement features like call return, call intercept, etc. -MC On Tue, Dec 18, 2012 at 7:39 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au<mailto:Sirish.MasurMohan@oa.com.au>> wrote: Hi Michael,
How are you physically connecting from FreeSWITCH to the PBX?
I connect this via E1 link - I have a Sangoma card installed on the FreeSWITCH machine. With regards, Sirish From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org>] On Behalf Of Michael Collins Sent: Wednesday, 19 December 2012 1:31 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? To trigger SIP registrations you'd need the PBX to have a SIP client. I'm assuming this is possible, but maybe that's a false assumption. How are you physically connecting from FreeSWITCH to the PBX? -MC On Tue, Dec 18, 2012 at 2:36 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au<mailto:Sirish.MasurMohan@oa.com.au>> wrote: Hey Guys, Would really appreciate if you could help me out here - isn't there a way to handle concurrent calls in the dial plan, especially when Lua scripts, accessing global variables, are executed on receiving calls? Is mod_fifo the closest I could get to handle concurrency (as Michael has explained)? If yes, how do I trigger SIP registrations, especially working with a PBX which I don't have full control of? With regards, Sirish From: Sirish Masur Mohan Sent: Tuesday, 18 December 2012 1:02 PM To: FreeSWITCH Users Help Subject: RE: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Hi Michael, Thanks for the reply.
You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions I am seen SIP clients such as X-Lite sending out the SIP registrations, but could you please clarify as to how this can be achieved in the PBX? The final production environment would be out in the customer's PBX, which I may not have complete control of..
What application are you building? I may not be able to provide the details because of the NDA with customer, but what I am trying to achieve is, to replace an existing IVR with FreeSWITCH in an old existing setup of the customer - that's the reason why we continue working with dialup modems!
With regards, Sirish From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Michael Collins Sent: Tuesday, 18 December 2012 6:23 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? You don't have to have actual human agents for mod_fifo. You could define a user for each modem and then manually "log in" those "agents" on the command line using the fifo_member API command. Something like this: fifo_member add fifo_name {fifo_member_wait=nowait}user/1234 Where 1234 is the user id of one of the modems. You would need a SIP registration from the PBX to FreeSWITCH for each of the modem extensions. Having modems go through a VoIP system sounds a bit scary. What application are you building? -MC On Sun, Dec 16, 2012 at 5:41 PM, Sirish Masur Mohan <Sirish.MasurMohan@oa.com.au<mailto:Sirish.MasurMohan@oa.com.au>> wrote: Hi William, Thanks for the reply. My setup is as follows: Client(Caller)->dialup modem->PBX->FreeSWITCH->PBX-> 4 dialup modems->Server(Receiver) I basically need FreeSWITCH to bridge the incoming call to the best external destination (out of the 4 available), so that the modem training, connection etc can take place smoothly, before exchange of data. I am not sure if mod_fifo would help me in this scenario, as, I would require an agent to dial in and read the fifo. Could you please clarify? Thanks! With regards, Sirish -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org> [mailto:freeswitch-users-bounces@lists.freeswitch.org<mailto:freeswitch-users-bounces@lists.freeswitch.org>] On Behalf Of William King Sent: Monday, 17 December 2012 10:47 AM To: freeswitch-users@lists.freeswitch.org<mailto:freeswitch-users@lists.freeswitch.org> Subject: Re: [Freeswitch-users] Newbie question: Executing Lua scripts for incoming calls, how concurrency is to be handled? Sounds like you want to take a look into mod_fifo. William King Senior Engineer Quentus Technologies, INC 1037 NE 65th St Suite 273 Seattle, WA 98115 Main: (877) 211-9337<tel:%28877%29%20211-9337> Office: (206) 388-4772<tel:%28206%29%20388-4772> Cell: (253) 686-5518<tel:%28253%29%20686-5518> william.king@quentustech.com<mailto:william.king@quentustech.com> _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org -- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org -- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org -- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users<http://lists.freeswitch.org/mailman/options/freeswitch-users> http://www.freeswitch.org _________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org<mailto:consulting@freeswitch.org> http://www.freeswitchsolutions.com FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com Official FreeSWITCH Sites http://www.freeswitch.org http://wiki.freeswitch.org http://www.cluecon.com FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org<mailto:FreeSWITCH-users@lists.freeswitch.org> http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org -- Michael S Collins Twitter: @mercutioviz http://www.FreeSWITCH.org http://www.ClueCon.com http://www.OSTAG.org
participants (4)
-
Michael Collins
-
Sirish Masur Mohan
-
Steven Ayre
-
William King