[asterisk-users] Asterisk 11, hangup-handlers, Local channels and channel originate [SOLVED]
Olivier
oza_4h07 at yahoo.fr
Tue Mar 26 03:03:37 CDT 2013
2013/3/26 Richard Mudgett <rmudgett at digium.com>
> > On 03/25/2013 05:17 PM, Olivier wrote:
> > > Hello,
> > >
> > > I'm giving hangup-handlers a try on a new Asterisk 11.2.1 setup.
> > > My plan is to use this handler to update my CDRs with values such
> > > as
> > > Asterish and Tech cause (see function HANGUP_CAUSE).
> > > I want to have my custom hangup-handler be run only once and when
> > > "the
> > > second channel" hangs up.
> > >
> > > At the moment, I'm issuing a couple of "channel originate
> > > Local/1 at mycontext1 extension 123456789 at mycontext2" commands.
> > >
> > > I'm observing that as I'm using expressions such as
> > > Local/1 at mycontext1,
> > > a Local <ZOMBIE> channel is hanged before the second channel stops
> > > ringing.
> > > When the second channel itself ends, my handler is not run anymore.
> > >
> > >
> > > What would you suggest me to do ?
> > > Should I delay my Set(CHANNEL(hangup_handler_wipe)= ...) statement
> > > till
> > > both channels are bridged together ?
> > >
> >
> > It is hard to say without seeing the dialplan that you're using. Most
> > likely, the hangup handler has been attached to one half of the Local
> > channel as opposed to the channel you want it attached to. Can you
> > include the full dialplan that you're using?
> >
> >
> > Yes, of course.
> > I'll simplify it and post it here ASAP.
> >
> >
> > Here it is:
> >
> > [hangup-handler]
> > exten => s,1,Verbose(0,Entering context ${CONTEXT} in channel
> > ${CHANNEL} with EXTEN and CID set to ${EXTEN} and ${CALLERID(num)})
> >
> >
> > [to-foobar]
> > exten => _X.,1,Verbose(0,Entering context ${CONTEXT} with EXTEN and
> > CID set to ${EXTEN} and ${CALLERID(num)})
> > same => n, Set(CHANNEL(hangup_handler_push)=hangup-handler,s,1)
> > same => n, Dial(SIP/foobar/${EXTEN})
> > same => n, Hangup()
> >
> >
> > [from-foobar]
> > exten => _X.,1,Verbose(0,Entering context ${CONTEXT} with EXTEN and
> > CID set to ${EXTEN} and ${CALLERID(num)})
> > same => n, Dial(SIP/foobar/${EXTEN})
> > same => n, Hangup()
> >
> >
> > The command I used is :
> > channel originate Local/7005 at from-foobar extension 7003 at to-foobar
> >
> > Console prints:
> > Entering context from-foobar with EXTEN and CID set to 7005 and
> > Entering context to-foobar with EXTEN and CID set to 7003 and
> > Entering context hangup-handler in channel
> > Local/7005 at from-foobar-00000008;1<ZOMBIE> with EXTEN and CID set to
> > s and
> >
> > The first line is printed at soon as Enter key is pressed.
> > The second and third lines are printed when originating channel
> > answers (here extension SIP/foobar/7005)
>
> The originate creates a chain of channels like so:
> SIP/foobar/7005 -- Local/7005 at from-foobar;1 -- Local/7005 at from-foobar;2
> -- SIP/foobar/7003
>
> You put the hangup handler on the Local/7005 at from-foobar;2 channel. When
> the local channel optimizes itself out, the hangup handler is run on the
> hanging up local channel.
>
> What you need to do is use a pre-dial handler to put the hangup handler on
> the SIP/foobar/7003 channel.
>
> Richard
>
> [1] https://wiki.asterisk.org/wiki/display/AST/Hangup+Handlers
> [2] https://wiki.asterisk.org/wiki/display/AST/Pre-Dial+Handlers
>
>
Thanks to the above suggestion, the dialplan bellow made it.
Thanks for helping.
[pre-dial-handler]
exten => s,1,Verbose(0,Entering context ${CONTEXT} in channel ${CHANNEL}
with EXTEN and CID set to ${EXTEN} and ${CALLERID(num)})
same => n, Set(CHANNEL(hangup_handler_push)=hangup-handler,s,1)
[hangup-handler]
exten => s,1,Verbose(0,Entering context ${CONTEXT} in channel ${CHANNEL}
with EXTEN and CID set to ${EXTEN} and ${CALLERID(num)})
[to-foobar]
exten => _X.,1,Verbose(0,Entering context ${CONTEXT} with EXTEN and CID set
to ${EXTEN} and ${CALLERID(num)})
; same => n, Set(CHANNEL(hangup_handler_push)=hangup-handler,s,1)
same => n, Dial(SIP/foobar/${EXTEN},,b(pre-dial-handler^s^1))
same => n, Hangup()
[from-foobar]
exten => _X.,1,Verbose(0,Entering context ${CONTEXT} with EXTEN and CID set
to ${EXTEN} and ${CALLERID(num)})
same => n, Dial(SIP/foobar/${EXTEN})
same => n, Hangup()
> --
> _____________________________________________________________________
> -- Bandwidth and Colocation Provided by http://www.api-digital.com --
> New to Asterisk? Join us for a live introductory webinar every Thurs:
> http://www.asterisk.org/hello
>
> asterisk-users mailing list
> To UNSUBSCRIBE or update options visit:
> http://lists.digium.com/mailman/listinfo/asterisk-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-users/attachments/20130326/3211b864/attachment.htm>
More information about the asterisk-users
mailing list