添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
What version of FreeSWITCH are you running?
-MC
Post by Isaac Jurado
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 at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110803/68280eae/attachment.html
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
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 at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Post by Avi Marcus
<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
Post by Avi Marcus
<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
<action application="set" data="session_in_hangup_hook=true"/>
<action application="export" data="api_hangup_hook=uuid_exists ${uuid}"/>
2011-08-03 19:01:30.609887 [DEBUG] switch_core_state_machine.c:492
Hangup Command with no Session
false
[...]
2011-08-03 19:01:30.645615 [DEBUG] switch_core_state_machine.c:492
Hangup Command with Session
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 at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Post by Avi Marcus
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)
Post by Isaac Jurado
Post by Avi Marcus
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
<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 at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
Post by Avi Marcus
If the channel is hung up, then it's hung up.. that's what the hangup
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
Post by Avi Marcus
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
Post by Isaac Jurado
Post by Avi Marcus
If the channel is hung up, then it's hung up.. that's what the hangup
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
Post by Avi Marcus
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 at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110803/4fbb7918/attachment.html
Post by Michael Collins
Just remember that once the call ends, the "session" object you have
is read-only.
Good to know.
Post by Michael Collins
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).
Post by Michael Collins
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
Post by Isaac Jurado
Post by Isaac Jurado
If our experiments provide a working proof of concept, we have two
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 at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110803/a80a953b/attachment.html
Post by Avi Marcus
If the channel is hung up, then it's hung up.. that's what the hangup
hook is, afaik.
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
Post by Isaac Jurado
Post by Avi Marcus
If the channel is hung up, then it's hung up.. that's what the hangup
hook is, afaik.
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
<action application="export" data="session_in_hangup_hook=true"/>
<action application="export" data="api_hangup_hook=luarun
transfer_check.lua ${uuid}"/>
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 at lists.freeswitch.org
http://lists.freeswitch.org/mailman/listinfo/freeswitch-users
UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users
http://www.freeswitch.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110804/6d530742/attachment.html
Post by Isaac Jurado
Post by Steven Ayre
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110804/d60dc1f9/attachment.html
Post by Michael Collins
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
Sorry, typo: that was supposed to be "api_reporting_hook" which I need to
document anyway. ;)
-MC
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110804/bc005821/attachment.html
Post by Michael Collins
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&go=Go

Regards.
--
Isaac Jurado
Internet Busines Solutions eConcept
Post by Isaac Jurado
Post by Michael Collins
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
http://wiki.freeswitch.org/wiki/Special:Search?search=channel_in_hangup_hook&go=Go
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.freeswitch.org/pipermail/freeswitch-users/attachments/20110805/894afb86/attachment.html
Post by Michael Collins
That's what I get for trying to do too much all at once. The correct
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
replies Do you think Karate is useful in practical situations? Please be honest? No fanboys or biased answer.? started 2009-03-24 21:40:15 UTC