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