Lua session originate
When I try to use lua to originate a call, I get this: freeswitch@internal> lua test_originate.lua -ERR encountered freeswitch@internal> 2011-04-12 13:03:17.806648 [ERR] mod_lua.cpp:191 Error in originate expected 4. .4 args, got 3 stack traceback: [C]: in function 'originate' /usr/local/freeswitch/scripts/test_originate.lua:3: in main chunk I'm using the following line of code: local new_session = freeswitch.Session(); new_session.originate(session, "sofia/gateway/mygatewayname/mynumber", 60); This is in the Wiki: session:originate local new_session = freeswitch.Session(); new_session.originate(session, dest[, timeout]); dest - quoted dialplan destanation. For example: "sofia/internal/1000@10.0.0.1" or "sofia/gateway/my_sip_provider/my_dest_number" timeout - origination timeout in seconds Note: in recent git versions, session.originate expects 4 arguments; the example above does not work (anymore?). What is the 4th arg? ----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com<mailto:eric@loopfx.com>
The fourth parameter is the switch_state_handler_table reference and for most uses(script language) you should just pass null but I dont use lua so I dont know the details on that. -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Lua-session-originate-tp626612... Sent from the freeswitch-users mailing list archive at Nabble.com.
Thanks Jeff, When I try NULL I get this: freeswitch@internal> 2011-04-12 14:49:31.582049 [ERR] mod_lua.cpp:191 Error in originate (arg 2), ex pected 'CoreSession *' got 'string' stack traceback: [C]: in function 'originate' /usr/local/freeswitch/scripts/test_originate.lua:3: in main chunk I've been digging through the source code, and I can't find where 4 args are required. I see this in freeswitch_lua.cpp: int Session::originate(CoreSession *a_leg_session, char *dest, int timeout) { int x = CoreSession::originate(a_leg_session, dest, timeout); if (x) { setLUA(L); } return x; } ----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Jeff Lenk Sent: Tuesday, April 12, 2011 2:42 PM To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Lua session originate The fourth parameter is the switch_state_handler_table reference and for most uses(script language) you should just pass null but I dont use lua so I dont know the details on that. -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Lua-session-originate-tp626612... Sent from the freeswitch-users mailing list archive at Nabble.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
Ok, so I got a little further by trial and error, and realized the 4th arg is due to lua function calling syntax. If you use the dot notation on a function declared with a colon, it expects "this" as the first arg. My current code looks like this: -- Originate an outbound call local new_session = freeswitch.Session(); new_session:originate(session, "sofia/gateway/affinity/17277762768", 60); new_session:waitForAnswer(session); prompt = "/home/eric/test1.wav" freeswitch.consoleLog("INFO", "About to play prompt file " .. prompt .."\n") new_session:streamFile(prompt) new_session:hangup() The scary thing about this code is that it crashed freeSwitch when I ran it. This is the last thing I saw in the logs: ----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Eric Beard Sent: Tuesday, April 12, 2011 3:15 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Lua session originate Thanks Jeff, When I try NULL I get this: freeswitch@internal> 2011-04-12 14:49:31.582049 [ERR] mod_lua.cpp:191 Error in originate (arg 2), ex pected 'CoreSession *' got 'string' stack traceback: [C]: in function 'originate' /usr/local/freeswitch/scripts/test_originate.lua:3: in main chunk I've been digging through the source code, and I can't find where 4 args are required. I see this in freeswitch_lua.cpp: int Session::originate(CoreSession *a_leg_session, char *dest, int timeout) { int x = CoreSession::originate(a_leg_session, dest, timeout); if (x) { setLUA(L); } return x; } ----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Jeff Lenk Sent: Tuesday, April 12, 2011 2:42 PM To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Lua session originate The fourth parameter is the switch_state_handler_table reference and for most uses(script language) you should just pass null but I dont use lua so I dont know the details on that. -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Lua-session-originate-tp626612... Sent from the freeswitch-users mailing list archive at Nabble.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 _______________________________________________ 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
Here is the tail of the logs. 2011-04-12 15:56:07.594051 [DEBUG] switch_channel.c:2656 (sofia/external/17277762768) Callstate Chan ge RINGING -> EARLY 2011-04-12 15:56:07.598555 [DEBUG] switch_ivr_originate.c:3412 Originate Resulted in Success: [sofia /external/17277762768] 2011-04-12 15:56:07.598555 [DEBUG] switch_cpp.cpp:1064 (sofia/external/17277762768) State Change CS_ CONSUME_MEDIA -> CS_SOFT_EXECUTE ----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Eric Beard Sent: Tuesday, April 12, 2011 4:02 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Lua session originate - freeswitch crash Ok, so I got a little further by trial and error, and realized the 4th arg is due to lua function calling syntax. If you use the dot notation on a function declared with a colon, it expects "this" as the first arg. My current code looks like this: -- Originate an outbound call local new_session = freeswitch.Session(); new_session:originate(session, "sofia/gateway/affinity/17277762768", 60); new_session:waitForAnswer(session); prompt = "/home/eric/test1.wav" freeswitch.consoleLog("INFO", "About to play prompt file " .. prompt .."\n") new_session:streamFile(prompt) new_session:hangup() The scary thing about this code is that it crashed freeSwitch when I ran it. This is the last thing I saw in the logs: ----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Eric Beard Sent: Tuesday, April 12, 2011 3:15 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Lua session originate Thanks Jeff, When I try NULL I get this: freeswitch@internal> 2011-04-12 14:49:31.582049 [ERR] mod_lua.cpp:191 Error in originate (arg 2), ex pected 'CoreSession *' got 'string' stack traceback: [C]: in function 'originate' /usr/local/freeswitch/scripts/test_originate.lua:3: in main chunk I've been digging through the source code, and I can't find where 4 args are required. I see this in freeswitch_lua.cpp: int Session::originate(CoreSession *a_leg_session, char *dest, int timeout) { int x = CoreSession::originate(a_leg_session, dest, timeout); if (x) { setLUA(L); } return x; } ----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Jeff Lenk Sent: Tuesday, April 12, 2011 2:42 PM To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Lua session originate The fourth parameter is the switch_state_handler_table reference and for most uses(script language) you should just pass null but I dont use lua so I dont know the details on that. -- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Lua-session-originate-tp626612... Sent from the freeswitch-users mailing list archive at Nabble.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 _______________________________________________ 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 _______________________________________________ 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
1) You are not running the latest GIT. Your scripts works fine on my development box. 2) the originate method is deprecated. you can just do local new_session = freeswitch.Session("sofia/gateway/affinity/17277762768", session); 3) In either case you should not be doing what you do in this script because the whole time you are playing the file to new_session the original session is blocked not reading or writing any audio. On Tue, Apr 12, 2011 at 3:02 PM, Eric Beard <eric@loopfx.com> wrote:
Ok, so I got a little further by trial and error, and realized the 4th arg is due to lua function calling syntax. If you use the dot notation on a function declared with a colon, it expects "this" as the first arg.
My current code looks like this:
-- Originate an outbound call local new_session = freeswitch.Session(); new_session:originate(session, "sofia/gateway/affinity/17277762768", 60); new_session:waitForAnswer(session); prompt = "/home/eric/test1.wav" freeswitch.consoleLog("INFO", "About to play prompt file " .. prompt .."\n") new_session:streamFile(prompt) new_session:hangup()
The scary thing about this code is that it crashed freeSwitch when I ran it.
This is the last thing I saw in the logs:
----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com
-----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Eric Beard Sent: Tuesday, April 12, 2011 3:15 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Lua session originate
Thanks Jeff,
When I try NULL I get this:
freeswitch@internal> 2011-04-12 14:49:31.582049 [ERR] mod_lua.cpp:191 Error in originate (arg 2), ex pected 'CoreSession *' got 'string' stack traceback: [C]: in function 'originate' /usr/local/freeswitch/scripts/test_originate.lua:3: in main chunk
I've been digging through the source code, and I can't find where 4 args are required. I see this in freeswitch_lua.cpp:
int Session::originate(CoreSession *a_leg_session, char *dest, int timeout) { int x = CoreSession::originate(a_leg_session, dest, timeout);
if (x) { setLUA(L); }
return x; }
----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com
-----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Jeff Lenk Sent: Tuesday, April 12, 2011 2:42 PM To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Lua session originate
The fourth parameter is the switch_state_handler_table reference and for most uses(script language) you should just pass null but I dont use lua so I dont know the details on that.
-- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Lua-session-originate-tp626612... Sent from the freeswitch-users mailing list archive at Nabble.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
_______________________________________________ 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
_______________________________________________ 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
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900
Thanks Anthony, I will update to latest. I last did a pull about 2 weeks ago, FreeSWITCH Version 1.0.head (git-8c5586b 2011-04-01 14-22-43 -0500). If I shouldn't be doing this in this script, then what is the recommended way to originate an outbound IVR call? My current production application uses Microsoft Speech Server to send outbound customer service calls, with a B2BUA I wrote to communicate with terminators. I'm switching my B2BUA out for FreeSwitch, and it's working great. But if possible I'd like to remove MSS from the equation altogether. Lua looks like a good way to control the call workflow. Should I be using ESL from an external application instead? Thanks for your time, ----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Anthony Minessale Sent: Tuesday, April 12, 2011 7:28 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Lua session originate - freeswitch crash 1) You are not running the latest GIT. Your scripts works fine on my development box. 2) the originate method is deprecated. you can just do local new_session = freeswitch.Session("sofia/gateway/affinity/17277762768", session); 3) In either case you should not be doing what you do in this script because the whole time you are playing the file to new_session the original session is blocked not reading or writing any audio. On Tue, Apr 12, 2011 at 3:02 PM, Eric Beard <eric@loopfx.com> wrote:
Ok, so I got a little further by trial and error, and realized the 4th arg is due to lua function calling syntax. If you use the dot notation on a function declared with a colon, it expects "this" as the first arg.
My current code looks like this:
-- Originate an outbound call local new_session = freeswitch.Session(); new_session:originate(session, "sofia/gateway/affinity/17277762768", 60); new_session:waitForAnswer(session); prompt = "/home/eric/test1.wav" freeswitch.consoleLog("INFO", "About to play prompt file " .. prompt .."\n") new_session:streamFile(prompt) new_session:hangup()
The scary thing about this code is that it crashed freeSwitch when I ran it.
This is the last thing I saw in the logs:
----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com
-----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Eric Beard Sent: Tuesday, April 12, 2011 3:15 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Lua session originate
Thanks Jeff,
When I try NULL I get this:
freeswitch@internal> 2011-04-12 14:49:31.582049 [ERR] mod_lua.cpp:191 Error in originate (arg 2), ex pected 'CoreSession *' got 'string' stack traceback: [C]: in function 'originate' /usr/local/freeswitch/scripts/test_originate.lua:3: in main chunk
I've been digging through the source code, and I can't find where 4 args are required. I see this in freeswitch_lua.cpp:
int Session::originate(CoreSession *a_leg_session, char *dest, int timeout) { int x = CoreSession::originate(a_leg_session, dest, timeout);
if (x) { setLUA(L); }
return x; }
----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com
-----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Jeff Lenk Sent: Tuesday, April 12, 2011 2:42 PM To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Lua session originate
The fourth parameter is the switch_state_handler_table reference and for most uses(script language) you should just pass null but I dont use lua so I dont know the details on that.
-- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Lua-session-originate-tp626612... Sent from the freeswitch-users mailing list archive at Nabble.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
_______________________________________________ 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
_______________________________________________ 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
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900 _______________________________________________ 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
I'm sort of in the same boat... I've been working on a project completely in LUA - using mod_lcr / mod_nibblebill etc - and another contributor wrote to migrate to ESL... Not that I'm against a challenge - just disappointed I spent so much time writing the LUA script to now have to convert to ESL. -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Eric Beard Sent: Wednesday, April 13, 2011 8:49 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Lua session originate - freeswitch crash Thanks Anthony, I will update to latest. I last did a pull about 2 weeks ago, FreeSWITCH Version 1.0.head (git-8c5586b 2011-04-01 14-22-43 -0500). If I shouldn't be doing this in this script, then what is the recommended way to originate an outbound IVR call? My current production application uses Microsoft Speech Server to send outbound customer service calls, with a B2BUA I wrote to communicate with terminators. I'm switching my B2BUA out for FreeSwitch, and it's working great. But if possible I'd like to remove MSS from the equation altogether. Lua looks like a good way to control the call workflow. Should I be using ESL from an external application instead? Thanks for your time, ----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Anthony Minessale Sent: Tuesday, April 12, 2011 7:28 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Lua session originate - freeswitch crash 1) You are not running the latest GIT. Your scripts works fine on my development box. 2) the originate method is deprecated. you can just do local new_session = freeswitch.Session("sofia/gateway/affinity/17277762768", session); 3) In either case you should not be doing what you do in this script because the whole time you are playing the file to new_session the original session is blocked not reading or writing any audio. On Tue, Apr 12, 2011 at 3:02 PM, Eric Beard <eric@loopfx.com> wrote:
Ok, so I got a little further by trial and error, and realized the 4th arg is due to lua function calling syntax. If you use the dot notation on a function declared with a colon, it expects "this" as the first arg.
My current code looks like this:
-- Originate an outbound call local new_session = freeswitch.Session(); new_session:originate(session, "sofia/gateway/affinity/17277762768", 60); new_session:waitForAnswer(session); prompt = "/home/eric/test1.wav" freeswitch.consoleLog("INFO", "About to play prompt file " .. prompt .."\n") new_session:streamFile(prompt) new_session:hangup()
The scary thing about this code is that it crashed freeSwitch when I ran it.
This is the last thing I saw in the logs:
----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com
-----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Eric Beard Sent: Tuesday, April 12, 2011 3:15 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Lua session originate
Thanks Jeff,
When I try NULL I get this:
freeswitch@internal> 2011-04-12 14:49:31.582049 [ERR] mod_lua.cpp:191 Error in originate (arg 2), ex pected 'CoreSession *' got 'string' stack traceback: [C]: in function 'originate' /usr/local/freeswitch/scripts/test_originate.lua:3: in main chunk
I've been digging through the source code, and I can't find where 4 args are required. I see this in freeswitch_lua.cpp:
int Session::originate(CoreSession *a_leg_session, char *dest, int timeout) { int x = CoreSession::originate(a_leg_session, dest, timeout);
if (x) { setLUA(L); }
return x; }
----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com
-----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Jeff Lenk Sent: Tuesday, April 12, 2011 2:42 PM To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Lua session originate
The fourth parameter is the switch_state_handler_table reference and for most uses(script language) you should just pass null but I dont use lua so I dont know the details on that.
-- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Lua-session-originate-tp626612 1p6266239.html Sent from the freeswitch-users mailing list archive at Nabble.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
_______________________________________________ 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
_______________________________________________ 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
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900 _______________________________________________ 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 _______________________________________________ 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
I've been fiddling around with things this morning and I am using a combination of PHP and Lua. I use php to simply originate the call (using regular sockets to talk to 8021, not the php mod for ESL, since I can't get it to compile). In the originate command I specify a Lua script that handles the rest of the call. I'm using the PHP functions described here: http://wiki.freeswitch.org/wiki/PHP_Event_Socket My PHP: $fp = event_socket_create("127.0.0.1", 8021, "ClueCon"); $channelVars = "{ignore_early_media=true,origination_caller_id_number=18778502010}"; $phoneNum = "17277762768"; $notificationId = "x"; $cmd = "bgapi originate $channelVars". "sofia/gateway/affinity/".$phoneNum." &lua('test2.lua $notificationId')"; echo "Sending command: $cmd"; $response = event_socket_request($fp, $cmd); echo $response; fclose($fp); My Lua: prompt = "/home/eric/test1.wav" session:streamFile(prompt) session:hangup() This is working for the very basic scenario of just waiting for the number to pick up, playing a wav, and then hanging up. If anybody can point out any major showstoppers that would prevent me from handling significant user interaction, I'd love to hear about them now. One of the things I'd like to do is incorporate pocketsphinx so that I can do voice reco. Is that possible from Lua? Thanks, ----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Robert Huddleston Sent: Wednesday, April 13, 2011 9:06 AM To: 'FreeSWITCH Users Help' Subject: Re: [Freeswitch-users] Lua session originate - freeswitch crash I'm sort of in the same boat... I've been working on a project completely in LUA - using mod_lcr / mod_nibblebill etc - and another contributor wrote to migrate to ESL... Not that I'm against a challenge - just disappointed I spent so much time writing the LUA script to now have to convert to ESL. -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Eric Beard Sent: Wednesday, April 13, 2011 8:49 AM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Lua session originate - freeswitch crash Thanks Anthony, I will update to latest. I last did a pull about 2 weeks ago, FreeSWITCH Version 1.0.head (git-8c5586b 2011-04-01 14-22-43 -0500). If I shouldn't be doing this in this script, then what is the recommended way to originate an outbound IVR call? My current production application uses Microsoft Speech Server to send outbound customer service calls, with a B2BUA I wrote to communicate with terminators. I'm switching my B2BUA out for FreeSwitch, and it's working great. But if possible I'd like to remove MSS from the equation altogether. Lua looks like a good way to control the call workflow. Should I be using ESL from an external application instead? Thanks for your time, ----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com -----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Anthony Minessale Sent: Tuesday, April 12, 2011 7:28 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Lua session originate - freeswitch crash 1) You are not running the latest GIT. Your scripts works fine on my development box. 2) the originate method is deprecated. you can just do local new_session = freeswitch.Session("sofia/gateway/affinity/17277762768", session); 3) In either case you should not be doing what you do in this script because the whole time you are playing the file to new_session the original session is blocked not reading or writing any audio. On Tue, Apr 12, 2011 at 3:02 PM, Eric Beard <eric@loopfx.com> wrote:
Ok, so I got a little further by trial and error, and realized the 4th arg is due to lua function calling syntax. If you use the dot notation on a function declared with a colon, it expects "this" as the first arg.
My current code looks like this:
-- Originate an outbound call local new_session = freeswitch.Session(); new_session:originate(session, "sofia/gateway/affinity/17277762768", 60); new_session:waitForAnswer(session); prompt = "/home/eric/test1.wav" freeswitch.consoleLog("INFO", "About to play prompt file " .. prompt .."\n") new_session:streamFile(prompt) new_session:hangup()
The scary thing about this code is that it crashed freeSwitch when I ran it.
This is the last thing I saw in the logs:
----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com
-----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Eric Beard Sent: Tuesday, April 12, 2011 3:15 PM To: FreeSWITCH Users Help Subject: Re: [Freeswitch-users] Lua session originate
Thanks Jeff,
When I try NULL I get this:
freeswitch@internal> 2011-04-12 14:49:31.582049 [ERR] mod_lua.cpp:191 Error in originate (arg 2), ex pected 'CoreSession *' got 'string' stack traceback: [C]: in function 'originate' /usr/local/freeswitch/scripts/test_originate.lua:3: in main chunk
I've been digging through the source code, and I can't find where 4 args are required. I see this in freeswitch_lua.cpp:
int Session::originate(CoreSession *a_leg_session, char *dest, int timeout) { int x = CoreSession::originate(a_leg_session, dest, timeout);
if (x) { setLUA(L); }
return x; }
----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com
-----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Jeff Lenk Sent: Tuesday, April 12, 2011 2:42 PM To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Lua session originate
The fourth parameter is the switch_state_handler_table reference and for most uses(script language) you should just pass null but I dont use lua so I dont know the details on that.
-- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Lua-session-originate-tp626612 1p6266239.html Sent from the freeswitch-users mailing list archive at Nabble.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
_______________________________________________ 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
_______________________________________________ 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
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900 _______________________________________________ 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 _______________________________________________ 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 _______________________________________________ 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
On Wed, Apr 13, 2011 at 6:59 AM, Eric Beard <eric@loopfx.com> wrote:
I've been fiddling around with things this morning and I am using a combination of PHP and Lua.
I use php to simply originate the call (using regular sockets to talk to 8021, not the php mod for ESL, since I can't get it to compile). In the originate command I specify a Lua script that handles the rest of the call.
I'm using the PHP functions described here:
http://wiki.freeswitch.org/wiki/PHP_Event_Socket
My PHP:
$fp = event_socket_create("127.0.0.1", 8021, "ClueCon"); $channelVars = "{ignore_early_media=true,origination_caller_id_number=18778502010}"; $phoneNum = "17277762768"; $notificationId = "x"; $cmd = "bgapi originate $channelVars". "sofia/gateway/affinity/".$phoneNum." &lua('test2.lua $notificationId')"; echo "Sending command: $cmd"; $response = event_socket_request($fp, $cmd); echo $response; fclose($fp);
My Lua:
prompt = "/home/eric/test1.wav" session:streamFile(prompt) session:hangup()
This is working for the very basic scenario of just waiting for the number to pick up, playing a wav, and then hanging up. If anybody can point out any major showstoppers that would prevent me from handling significant user interaction, I'd love to hear about them now. One of the things I'd like to do is incorporate pocketsphinx so that I can do voice reco. Is that possible from Lua?
You can run pretty much any dialplan application from Lua using the session:execute method. I don't see any issues with you originating the calls via event socket and then handling the answered calls with a Lua dp script. -MC
I didn't say you can't use LUA The only point I was trying to make is: if you are running the lua script on an inbound call, then you just create a new session and ignore the one the call came in on you have an issue. lua is best when you are trying to make an IVR or do advanced logic that is too much for the XML dialplan. You have a single channel and you use the channel data to do things on that channel. One big mistake people tend to make is they think that embedded scripting is a shortcut to making complex apps without thinking through the requirements. Also doing things like trying to setup and bridge 2 channels together in lua manually is unwise. The originate syntax is the same everywhere including with the bridge app. The best thing to do is use your script to figure out the params you need for the originate syntax of the B leg then simply set that as a variable, exit the script and pass that variable to the bridge app from your dialplan. If you need to be fully asynchronous you for sure want to consider ESL. On Wed, Apr 13, 2011 at 10:01 AM, Michael Collins <msc@freeswitch.org> wrote:
On Wed, Apr 13, 2011 at 6:59 AM, Eric Beard <eric@loopfx.com> wrote:
I've been fiddling around with things this morning and I am using a combination of PHP and Lua.
I use php to simply originate the call (using regular sockets to talk to 8021, not the php mod for ESL, since I can't get it to compile). In the originate command I specify a Lua script that handles the rest of the call.
I'm using the PHP functions described here:
http://wiki.freeswitch.org/wiki/PHP_Event_Socket
My PHP:
$fp = event_socket_create("127.0.0.1", 8021, "ClueCon"); $channelVars = "{ignore_early_media=true,origination_caller_id_number=18778502010}"; $phoneNum = "17277762768"; $notificationId = "x"; $cmd = "bgapi originate $channelVars". "sofia/gateway/affinity/".$phoneNum." &lua('test2.lua $notificationId')"; echo "Sending command: $cmd"; $response = event_socket_request($fp, $cmd); echo $response; fclose($fp);
My Lua:
prompt = "/home/eric/test1.wav" session:streamFile(prompt) session:hangup()
This is working for the very basic scenario of just waiting for the number to pick up, playing a wav, and then hanging up. If anybody can point out any major showstoppers that would prevent me from handling significant user interaction, I'd love to hear about them now. One of the things I'd like to do is incorporate pocketsphinx so that I can do voice reco. Is that possible from Lua?
You can run pretty much any dialplan application from Lua using the session:execute method. I don't see any issues with you originating the calls via event socket and then handling the answered calls with a Lua dp script. -MC _______________________________________________ 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
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900
1) You are not running the latest GIT. Your scripts works fine on my development box. 2) the originate method is deprecated. you can just do local new_session = freeswitch.Session("sofia/gateway/affinity/17277762768", session); 3) In either case you should not be doing what you do in this script because the whole time you are playing the file to new_session the original session is blocked not reading or writing any audio. On Tue, Apr 12, 2011 at 2:14 PM, Eric Beard <eric@loopfx.com> wrote:
Thanks Jeff,
When I try NULL I get this:
freeswitch@internal> 2011-04-12 14:49:31.582049 [ERR] mod_lua.cpp:191 Error in originate (arg 2), ex pected 'CoreSession *' got 'string' stack traceback: [C]: in function 'originate' /usr/local/freeswitch/scripts/test_originate.lua:3: in main chunk
I've been digging through the source code, and I can't find where 4 args are required. I see this in freeswitch_lua.cpp:
int Session::originate(CoreSession *a_leg_session, char *dest, int timeout) { int x = CoreSession::originate(a_leg_session, dest, timeout);
if (x) { setLUA(L); }
return x; }
----------------------- Eric Z. Beard, CTO Loop LLC w (877) 850-2010 x9249 m (727) 776-2768 eric@loopfx.com
-----Original Message----- From: freeswitch-users-bounces@lists.freeswitch.org [mailto:freeswitch-users-bounces@lists.freeswitch.org] On Behalf Of Jeff Lenk Sent: Tuesday, April 12, 2011 2:42 PM To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] Lua session originate
The fourth parameter is the switch_state_handler_table reference and for most uses(script language) you should just pass null but I dont use lua so I dont know the details on that.
-- View this message in context: http://freeswitch-users.2379917.n2.nabble.com/Lua-session-originate-tp626612... Sent from the freeswitch-users mailing list archive at Nabble.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
_______________________________________________ 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
-- Anthony Minessale II FreeSWITCH http://www.freeswitch.org/ ClueCon http://www.cluecon.com/ Twitter: http://twitter.com/FreeSWITCH_wire AIM: anthm MSN:anthony_minessale@hotmail.com GTALK/JABBER/PAYPAL:anthony.minessale@gmail.com IRC: irc.freenode.net #freeswitch FreeSWITCH Developer Conference sip:888@conference.freeswitch.org googletalk:conf+888@conference.freeswitch.org pstn:+19193869900
participants (5)
-
Anthony Minessale
-
Eric Beard
-
Jeff Lenk
-
Michael Collins
-
Robert Huddleston