Hi, I've been playing with the "api_hangup_hook" dialplan setting. However, it only seems to be executing when the A-leg (originator) hangs up. Is there any way to execute such a hook from all the potential B-legs of the call? Thanks in advance. -- Isaac Jurado Internet Busines Solutions eConcept
What version of FreeSWITCH are you running? -MC On Wed, Aug 3, 2011 at 8:49 AM, Isaac Jurado <ijurado@econcept.es> wrote:
Hi,
I've been playing with the "api_hangup_hook" dialplan setting. However, it only seems to be executing when the A-leg (originator) hangs up. Is there any way to execute such a hook from all the potential B-legs of the call?
Thanks in advance.
-- Isaac Jurado Internet Busines Solutions eConcept
_______________________________________________ Join us at ClueCon 2011, Aug 9-11, Chicago http://www.cluecon.com 877-7-4ACLUE
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
Yes, you can export it, "nolocal" to activate only on the B leg, e.g.: <action application="export" data="nolocal:api_hangup_hook=lua file.lua"/> Or.. set the variable in the bridge string. -Avi On Wed, Aug 3, 2011 at 6:49 PM, Isaac Jurado <ijurado@econcept.es> wrote:
Hi,
I've been playing with the "api_hangup_hook" dialplan setting. However, it only seems to be executing when the A-leg (originator) hangs up. Is there any way to execute such a hook from all the potential B-legs of the call?
Thanks in advance.
-- Isaac Jurado Internet Busines Solutions eConcept
_______________________________________________ Join us at ClueCon 2011, Aug 9-11, Chicago http://www.cluecon.com 877-7-4ACLUE
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, Aug 3, 2011 at 6:09 PM, Avi Marcus <avi@avimarcus.net> wrote:
Yes, you can export it, "nolocal" to activate only on the B leg, e.g.:
<action application="export" data="nolocal:api_hangup_hook=lua file.lua"/>
It works! Thanks a lot. Now I have a small problem, the channels seem to be destroyed or unaccessible when the hangup hook is executed. I tested a dialplan with the following line: <action application="set" data="session_in_hangup_hook=true"/> <action application="export" data="api_hangup_hook=uuid_exists ${uuid}"/> And the FS log reports that none of the legs exists: 2011-08-03 19:01:30.609887 [DEBUG] switch_core_state_machine.c:492 Hangup Command with no Session uuid_exists(2bd2ce25-99fe-41fe-bcfe-d8224a9d6f18): false [...] 2011-08-03 19:01:30.645615 [DEBUG] switch_core_state_machine.c:492 Hangup Command with Session uuid_exists(2bd2ce25-99fe-41fe-bcfe-d8224a9d6f18): false This shows that the export works, as the hook is executed twice. Although the ${uuid} is expanded only once. But it's curious as the channel uuid where the hook is beign executed has not been destroyed yet. Cheers. -- Isaac Jurado Internet Busines Solutions eConcept
I'm not sure exactly what you are trying to do, but yes, the ${uuid} is expanded at the time of the "hunt" in the dialplan, before the second leg was even created. -Avi Marcus On Wed, Aug 3, 2011 at 8:24 PM, Isaac Jurado <ijurado@econcept.es> wrote:
On Wed, Aug 3, 2011 at 6:09 PM, Avi Marcus <avi@avimarcus.net> wrote:
Yes, you can export it, "nolocal" to activate only on the B leg, e.g.:
<action application="export" data="nolocal:api_hangup_hook=lua file.lua"/>
It works! Thanks a lot. Now I have a small problem, the channels seem to be destroyed or unaccessible when the hangup hook is executed. I tested a dialplan with the following line:
<action application="set" data="session_in_hangup_hook=true"/> <action application="export" data="api_hangup_hook=uuid_exists ${uuid}"/>
And the FS log reports that none of the legs exists:
2011-08-03 19:01:30.609887 [DEBUG] switch_core_state_machine.c:492 Hangup Command with no Session uuid_exists(2bd2ce25-99fe-41fe-bcfe-d8224a9d6f18): false [...] 2011-08-03 19:01:30.645615 [DEBUG] switch_core_state_machine.c:492 Hangup Command with Session uuid_exists(2bd2ce25-99fe-41fe-bcfe-d8224a9d6f18): false
This shows that the export works, as the hook is executed twice. Although the ${uuid} is expanded only once. But it's curious as the channel uuid where the hook is beign executed has not been destroyed yet.
Cheers.
-- Isaac Jurado Internet Busines Solutions eConcept
_______________________________________________ Join us at ClueCon 2011, Aug 9-11, Chicago http://www.cluecon.com 877-7-4ACLUE
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, Aug 3, 2011 at 7:39 PM, Avi Marcus <avi@avimarcus.net> wrote:
I'm not sure exactly what you are trying to do, but yes, the ${uuid} is expanded at the time of the "hunt" in the dialplan, before the second leg was even created.
My original intention was to set a channel variable from the api_hangup_hook: <action application="export" data="nolocal:api_hangup_hook=uuid_setvar ${uuid} fooooo baaaaar"/> But as the expanded ${uuid} does not exist, the uuid_setvar command complains. Cheers. -- Isaac Jurado Internet Busines Solutions eConcept
If the channel is hung up, then it's hung up.. that's what the hangup hook is, afaik. If you look at the wiki page for this: http://wiki.freeswitch.org/wiki/Variable_session_in_hangup_hook it only says that you can "access" the variable, not that the channel still exists or that you can set them. Why do you need to use a hangup hook to set a variable? can't you set it at the start? Or import B leg into A leg's CDRs? -Avi Marcus 718-989-9485 (USA) 054-844-3271 (Israel Kosher) 077-228-5055 (Israel Landline) 020-3519-3606 (UK) On Wed, Aug 3, 2011 at 8:47 PM, Isaac Jurado <ijurado@econcept.es> wrote:
On Wed, Aug 3, 2011 at 7:39 PM, Avi Marcus <avi@avimarcus.net> wrote:
I'm not sure exactly what you are trying to do, but yes, the ${uuid} is expanded at the time of the "hunt" in the dialplan, before the second leg was even created.
My original intention was to set a channel variable from the api_hangup_hook:
<action application="export" data="nolocal:api_hangup_hook=uuid_setvar ${uuid} fooooo baaaaar"/>
But as the expanded ${uuid} does not exist, the uuid_setvar command complains.
Cheers.
-- Isaac Jurado Internet Busines Solutions eConcept
_______________________________________________ Join us at ClueCon 2011, Aug 9-11, Chicago http://www.cluecon.com 877-7-4ACLUE
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, Aug 3, 2011 at 7:56 PM, Avi Marcus <avi@avimarcus.net> wrote:
If the channel is hung up, then it's hung up.. that's what the hangup hook is, afaik. If you look at the wiki page for this: http://wiki.freeswitch.org/wiki/Variable_session_in_hangup_hook it only says that you can "access" the variable, not that the channel still exists or that you can set them.
It looks that the session object is only available through bindings like mod_lua. I'll have to check
Why do you need to use a hangup hook to set a variable? can't you set it at the start? Or import B leg into A leg's CDRs?
It's a bit tricker than that. We are trying to implement a stateless CDR processing and billing mechanism that works also across call transfers. As I said, we will probably end up defining a Lua hook. Thanks again for your quick response. Cheers. -- Isaac Jurado Internet Busines Solutions eConcept
Just remember that once the call ends, the "session" object you have is read-only. You can still do interesting things, but you cannot alter CDRs after the call ends, at least not in a session hangup hook. You are better off with XML CDRs and post-call logic. With all of the screwy transfer scenarios you have to account for you will absolutely need to do some post-processing logic. Sounds like lots of "fun". :P -MC On Wed, Aug 3, 2011 at 12:14 PM, Isaac Jurado <ijurado@econcept.es> wrote:
On Wed, Aug 3, 2011 at 7:56 PM, Avi Marcus <avi@avimarcus.net> wrote:
If the channel is hung up, then it's hung up.. that's what the hangup hook is, afaik. If you look at the wiki page for this: http://wiki.freeswitch.org/wiki/Variable_session_in_hangup_hook it only says that you can "access" the variable, not that the channel still exists or that you can set them.
It looks that the session object is only available through bindings like mod_lua. I'll have to check
Why do you need to use a hangup hook to set a variable? can't you set it at the start? Or import B leg into A leg's CDRs?
It's a bit tricker than that. We are trying to implement a stateless CDR processing and billing mechanism that works also across call transfers.
As I said, we will probably end up defining a Lua hook.
Thanks again for your quick response.
Cheers.
-- Isaac Jurado Internet Busines Solutions eConcept
_______________________________________________ Join us at ClueCon 2011, Aug 9-11, Chicago http://www.cluecon.com 877-7-4ACLUE
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, Aug 3, 2011 at 9:36 PM, Michael Collins <msc@freeswitch.org> wrote:
Just remember that once the call ends, the "session" object you have is read-only.
Good to know.
You can still do interesting things, but you cannot alter CDRs after the call ends, at least not in a session hangup hook.
These days we are trying to modify other channels variables from the hangup hook (channels like the ones involved in whatever kind of transfer).
You are better off with XML CDRs and post-call logic. With all of the screwy transfer scenarios you have to account for you will absolutely need to do some post-processing logic. Sounds like lots of "fun". :P
Fun indeed. Our ideal target would be to have each CDR self-contained. In general, we only want to bill the A-leg CDRs as they are the originators. However, some B-leg CDRs need to be billed if they were created by a transfer and some A-leg CDRs can be discarded if they participated in an attended transfer. As you rightfully mentioned, when transfers are chained is where the obscure scenarios arise. If our experiments provide a working proof of concept, we have two choices left: 1. Subscribe to CHANNEL_STATE events in order to catch transfer directly from event socket. But we would be mixing mod_xml_cdr, mod_xml_curl and event socket altogether, so we want to avoid that. 2. Forget about stateless CDRs and pray (or inspect the source code) for mod_xml_cdr generating originator CDRs last, always. If anybody is interested, I can keep him/her informed. Cheers. -- Isaac Jurado Internet Busines Solutions eConcept
One other thing you might want to do is look at the callflows at the end of each xml cdr. they paint a picture of "what really happened" on the call and might give you the information that you need. -MC On Wed, Aug 3, 2011 at 1:02 PM, Isaac Jurado <ijurado@econcept.es> wrote:
On Wed, Aug 3, 2011 at 10:00 PM, Isaac Jurado <ijurado@econcept.es> wrote:
If our experiments provide a working proof of concept, we have two choices left:
That should read: «if our experiments DON'T provide»
Regards.
-- Isaac Jurado Internet Busines Solutions eConcept
_______________________________________________ Join us at ClueCon 2011, Aug 9-11, Chicago http://www.cluecon.com 877-7-4ACLUE
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, Aug 3, 2011 at 7:56 PM, Avi Marcus <avi@avimarcus.net> wrote:
If the channel is hung up, then it's hung up.. that's what the hangup hook is, afaik. If you look at the wiki page for this: http://wiki.freeswitch.org/wiki/Variable_session_in_hangup_hook it only says that you can "access" the variable, not that the channel still exists or that you can set them.
Ok. I still have some problems with this. My dialplan contains the following: <action application="export" data="session_in_hangup_hook=true"/> <action application="export" data="api_hangup_hook=luarun transfer_check.lua ${uuid}"/> The transfer_check.lua script is the following: session = freeswitch.Session(argv[1]) local cause = session:hangupCause() if cause == "ATTENDED_TRANSFER" or cause == "BLIND_TRANSFER" then api = freeswitch.API() api.execute("log", "NOTICE Transfer detected, billsec is " .. session:getVariable("billsec")) end The problem is that, as already discussed, the channel no longer exists so the UUID is not referring to anything. Basically, my question is: How do you obtain the session object in a hangup hook? Cheers. -- Isaac Jurado Internet Busines Solutions eConcept
Is this any use? http://wiki.freeswitch.org/wiki/Mod_lua#Special_Case:_env_object -Steve On 4 August 2011 10:03, Isaac Jurado <ijurado@econcept.es> wrote:
On Wed, Aug 3, 2011 at 7:56 PM, Avi Marcus <avi@avimarcus.net> wrote:
If the channel is hung up, then it's hung up.. that's what the hangup hook is, afaik. If you look at the wiki page for this: http://wiki.freeswitch.org/wiki/Variable_session_in_hangup_hook it only says that you can "access" the variable, not that the channel still exists or that you can set them.
Ok. I still have some problems with this. My dialplan contains the following:
<action application="export" data="session_in_hangup_hook=true"/> <action application="export" data="api_hangup_hook=luarun transfer_check.lua ${uuid}"/>
The transfer_check.lua script is the following:
session = freeswitch.Session(argv[1]) local cause = session:hangupCause()
if cause == "ATTENDED_TRANSFER" or cause == "BLIND_TRANSFER" then api = freeswitch.API() api.execute("log", "NOTICE Transfer detected, billsec is " .. session:getVariable("billsec")) end
The problem is that, as already discussed, the channel no longer exists so the UUID is not referring to anything.
Basically, my question is: How do you obtain the session object in a hangup hook?
Cheers.
-- Isaac Jurado Internet Busines Solutions eConcept
_______________________________________________ Join us at ClueCon 2011, Aug 9-11, Chicago http://www.cluecon.com 877-7-4ACLUE
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 Thu, Aug 4, 2011 at 3:05 PM, Steven Ayre <steveayre@gmail.com> wrote:
Is this any use?
http://wiki.freeswitch.org/wiki/Mod_lua#Special_Case:_env_object
Holly crap, I'm blind! I've visited the mod_lua page at least fifty times and I didn't see that. I feel embarrassed. Thank you so much. -- Isaac Jurado Internet Busines Solutions eConcept
On Thu, Aug 4, 2011 at 6:18 AM, Isaac Jurado <ijurado@econcept.es> wrote:
On Thu, Aug 4, 2011 at 3:05 PM, Steven Ayre <steveayre@gmail.com> wrote:
Is this any use?
http://wiki.freeswitch.org/wiki/Mod_lua#Special_Case:_env_object
Holly crap, I'm blind! I've visited the mod_lua page at least fifty times and I didn't see that. I feel embarrassed.
To help connect the dots I added some links to/from that Lua wiki page and channel_in_hangup_hook and also api_hangup_hook and reporting_hangup_hook. -MC
On Fri, Aug 5, 2011 at 2:13 AM, Michael Collins <msc@freeswitch.org> wrote:
To help connect the dots I added some links to/from that Lua wiki page and channel_in_hangup_hook and also api_hangup_hook and reporting_hangup_hook.
That "channel_in_hangup_hook" sounds promising to me, although I can't find any mention of it in the wiki: http://wiki.freeswitch.org/wiki/Special:Search?search=channel_in_hangup_hook... Regards. -- Isaac Jurado Internet Busines Solutions eConcept
On Fri, Aug 5, 2011 at 2:54 AM, Isaac Jurado <ijurado@econcept.es> wrote:
On Fri, Aug 5, 2011 at 2:13 AM, Michael Collins <msc@freeswitch.org> wrote:
To help connect the dots I added some links to/from that Lua wiki page and channel_in_hangup_hook and also api_hangup_hook and reporting_hangup_hook.
That "channel_in_hangup_hook" sounds promising to me, although I can't find any mention of it in the wiki:
http://wiki.freeswitch.org/wiki/Special:Search?search=channel_in_hangup_hook...
That's what I get for trying to do too much all at once. The correct chan var name is: session_in_hangup_hook Sorry... -MC
On Fri, Aug 5, 2011 at 7:08 PM, Michael Collins <msc@freeswitch.org> wrote:
That's what I get for trying to do too much all at once. The correct chan var name is: session_in_hangup_hook Sorry...
Heh, I was washing de dishes and I just realized you were meaning that. And I was going to write an apology too. Cheers and thanks for all. -- Isaac Jurado Internet Busines Solutions eConcept
participants (4)
-
Avi Marcus
-
Isaac Jurado
-
Michael Collins
-
Steven Ayre