can't get channel variables after hangup
I set this in my dialplan : <action application="set" data="session_in_hangup_hook=true"/> <action application="set" data="api_hangup_hook=system /usr/local/bin/php /usr/local/freeswitch/scripts/php/test.php ${uuid}"/> and this in test.php: exec("/usr/local/freeswitch/bin/fs_cli -x \"uuid_getvar ".$argv[1]." test_var\"", $exTabRet, $req); it results : -ERR No Such Channel! I tried to replace ${uuid} by ${call_uuid} without success. Thanks Franck
This won't work. The "session_in_hangup_hook" literally means that the $session object is available in the hangup hook script. You need to use Lua, Perl, or Javascript to access the $session object. What you are doing is actually trying to access a uuid that does not exist. Once the call is over it's gone. The "session" object will be available only in the script that is called in the hangup hook. Here's a simple script you can tinker with: -- hook-test.lua dat = env:serialize() --freeswitch.consoleLog("INFO","Here you go:\n" .. dat .. "\nn") uuid = env:getHeader("uuid") freeswitch.consoleLog("INFO","Inside hangup hook, uuid is: " .. dat .. "\n") my_var = env:getHeader("my_custom_var") freeswitch.consoleLog("INFO","my_custom_var is '" .. dat .. "'\n") api = freeswitch.API() res = api:execute("uuid_dump",uuid) freeswitch.consoleLog("INFO","result of 'uuid_dump " .. uuid .. "' is:\n" .. res .. "\n\n") Hopefully that will illustrate the issue... -MC On Wed, Dec 1, 2010 at 8:53 AM, Madovsky <infos@madovsky.org> wrote:
I set this in my dialplan :
<action application="set" data="session_in_hangup_hook=true"/> <action application="set" data="api_hangup_hook=system /usr/local/bin/php /usr/local/freeswitch/scripts/php/test.php ${uuid}"/> and this in test.php:
exec("/usr/local/freeswitch/bin/fs_cli -x \"uuid_getvar ".$argv[1]." test_var\"", $exTabRet, $req);
it results :
-ERR No Such Channel!
I tried to replace ${uuid} by ${call_uuid} without success.
Thanks
Franck
_______________________________________________ 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 Mike, and with PHP is $session available ? ----- Original Message ----- From: Michael Collins To: FreeSWITCH Users Help Sent: Wednesday, December 01, 2010 3:48 PM Subject: Re: [Freeswitch-users] can't get channel variables after hangup This won't work. The "session_in_hangup_hook" literally means that the $session object is available in the hangup hook script. You need to use Lua, Perl, or Javascript to access the $session object. What you are doing is actually trying to access a uuid that does not exist. Once the call is over it's gone. The "session" object will be available only in the script that is called in the hangup hook. Here's a simple script you can tinker with: -- hook-test.lua dat = env:serialize() --freeswitch.consoleLog("INFO","Here you go:\n" .. dat .. "\nn") uuid = env:getHeader("uuid") freeswitch.consoleLog("INFO","Inside hangup hook, uuid is: " .. dat .. "\n") my_var = env:getHeader("my_custom_var") freeswitch.consoleLog("INFO","my_custom_var is '" .. dat .. "'\n") api = freeswitch.API() res = api:execute("uuid_dump",uuid) freeswitch.consoleLog("INFO","result of 'uuid_dump " .. uuid .. "' is:\n" .. res .. "\n\n") Hopefully that will illustrate the issue... -MC On Wed, Dec 1, 2010 at 8:53 AM, Madovsky <infos@madovsky.org> wrote: I set this in my dialplan : <action application="set" data="session_in_hangup_hook=true"/> <action application="set" data="api_hangup_hook=system /usr/local/bin/php /usr/local/freeswitch/scripts/php/test.php ${uuid}"/> and this in test.php: exec("/usr/local/freeswitch/bin/fs_cli -x \"uuid_getvar ".$argv[1]." test_var\"", $exTabRet, $req); it results : -ERR No Such Channel! I tried to replace ${uuid} by ${call_uuid} without success. Thanks Franck _______________________________________________ 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
Date: Wed, 1 Dec 2010 13:11:41 -0800 From: msc@freeswitch.org To: freeswitch-users@lists.freeswitch.org Subject: Re: [Freeswitch-users] can't get channel variables after hangup On Wed, Dec 1, 2010 at 12:59 PM, Madovsky <infos@madovsky.org> wrote: Thanks Mike, and with PHP is $session available ? No, it's only available in the "built in" languages: Perl, Lua, and Javascript. -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
Ok understood. but maybe I took the wrong way to catch the mod_spandsp variables fax_success and fax_result_text. I would like to add some examples on wiki soon if anyone knows how to catch them in a dialplan. Thanks Franck ----- Original Message ----- From: Michael Collins To: FreeSWITCH Users Help Sent: Wednesday, December 01, 2010 4:11 PM Subject: Re: [Freeswitch-users] can't get channel variables after hangup On Wed, Dec 1, 2010 at 12:59 PM, Madovsky <infos@madovsky.org> wrote: Thanks Mike, and with PHP is $session available ? No, it's only available in the "built in" languages: Perl, Lua, and Javascript. -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
on a related note, i wanted to point out that if you're already inside a running script and need to perform actions when the call is hung up, you can do it right inside the script, no need to set a hangup hook. in this case, when the call hangs up, session:ready() (in Lua's case) returns false, the entire session object is still available (including channel variables), and you can perform hangup tasks and end the script when you're finished. the fact that FreeSWITCH allows your script to continue running after hangup is quite handy, but it also means that you should be thorough in your use of session:ready() to ensure the call is still up when you're taking actions that depend on it. this is especially important when using loops in your script -- very unpleasant things can happen if you don't include session:ready() in your loop conditional! hope this further clarification helps. chad On Dec 1, 2010, at 12:48 PM, Michael Collins wrote:
This won't work. The "session_in_hangup_hook" literally means that the $session object is available in the hangup hook script. You need to use Lua, Perl, or Javascript to access the $session object. What you are doing is actually trying to access a uuid that does not exist. Once the call is over it's gone. The "session" object will be available only in the script that is called in the hangup hook.
participants (4)
-
Brian Campbell
-
Chad Phillips -- Apartment Lines
-
Madovsky
-
Michael Collins