<div dir="ltr">FYI, we found that our peers don't hangup properly. But we would still like to know how to get the peer's hangup handler to fire upon peer hangup, because right now it corrupts our globals by firing after the caller's hangup handler.</div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 5, 2018 at 5:40 PM, David P <span dir="ltr"><<a href="mailto:davidswalkabout@gmail.com" target="_blank">davidswalkabout@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">FWIW, I added the following after the Dial, and it doesn't appear in cli after peer hangup:<div><br></div><div>same => n,NoOp(After Dial ${AddressToReachPeer})<br></div><div><br></div><div>I also tried putting 'g' before the 'b'.</div><div><br></div><div>I also tried removing the context headers of the hangup handlers and predial handler, and just referring to those by extensions. No difference.</div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 5, 2018 at 3:17 PM, David P <span dir="ltr"><<a href="mailto:davidswalkabout@gmail.com" target="_blank">davidswalkabout@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">This has been super-helpful, Eric. However, the 

<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">handleHangupByPeer</span> priorities below are still not run when the peer hangs-up. The last line in the cli when the peer hangs-up is still:<div>Strict RTP learning complete - Locking on source address</div><div>(Although sometimes there is also: Retransmission timeout reached on transmission)<br><div><br></div><div><div> same => n(callPeer),Set(GLOBAL(CB${Ind<wbr>exIntoPeers}CurrentCallsCount)<wbr>=$[${PeerCurrentCallsCount} + 1])</div><div> ; Ensure that hangup by caller/inbound-channel will invoke handleHangupByCaller.</div><div> same => n,Set(CHANNEL(hangup_handler_p<wbr>ush)=handleHangupByCaller,s,1(<wbr>args))</div><div> same => n,Set(AddressToReachPeer=SIP/$<wbr>{EXTEN:0:4}@${PeerBeingConside<wbr>red})</div><div> ; Ensure that the channel of the peer (i.e. outbound-channel) is configured with hangup handler.</div><div> same => n,Dial(${AddressToReachPeer},,<wbr>b(beforeDialingPeerConfigureIt<wbr>sChannelForPeerHangupHandling^<wbr>s^1))</div><div> same => n,Hangup</div><div> </div><div>[beforeDialingPeerConfigureIts<wbr>ChannelForPeerHangupHandling]</div><div>exten => s,1,Set(CHANNEL(hangup_handler<wbr>_push)=handleHangupByPeer,s,1(<wbr>args))</div><div> same => n,Return</div><div> </div><div>[handleHangupByPeer]</div><div> ; Ensure that GLOBAL(CB${IndexIntoPeers}Curr<wbr>entCallsCount) is decremented after hangup, and end-of-call-epoch is set.</div><div>exten => s,1,NoOp(${PeerBeingConsidered<wbr>} peer channel: Entered handleHangupByCallerOrPeer Calls ${CB${IndexIntoPeers}CurrentCa<wbr>llsCount})</div><div> same => n,Set(GLOBAL(CB${IndexIntoPeer<wbr>s}CurrentCallsCount)=$[${CB${I<wbr>ndexIntoPeers}CurrentCallsCoun<wbr>t} - 1])</div><span><div> same => n,Set(GLOBAL(${PeerBeingConsid<wbr>ered}EpochAtCallEnd)=${EPOCH})</div><div> same => n,Return</div><div> </div></span><div>[handleHangupByCaller]</div><div> ; Ensure that GLOBAL(CB${IndexIntoPeers}Curr<wbr>entCallsCount) is decremented after hangup, and end-of-call-epoch is set.</div><div>exten => s,1,NoOp(${PeerBeingConsidered<wbr>} caller channel: Entered handleHangupByCallerOrPeer Calls ${CB${IndexIntoPeers}CurrentCa<wbr>llsCount})</div><div> same => n,Set(GLOBAL(CB${IndexIntoPeer<wbr>s}CurrentCallsCount)=$[${CB${I<wbr>ndexIntoPeers}CurrentCallsCoun<wbr>t} - 1])</div><span><div> same => n,Set(GLOBAL(${PeerBeingConsid<wbr>ered}EpochAtCallEnd)=${EPOCH})</div><div> same => n,Return</div></span></div><div><br></div><div><br></div><div>When the caller hangs-up, <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">handleHangupByCaller is run first, then <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">handleHangupByPeer runs. (And strangely, the value of global <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">CB${IndexIntoPeers}Curr<wbr>entCallsCount isn't accessible in 

<span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">handleHangupByPeer.</span>)</span></span></span></div><div><br></div><div>Cheers,</div><div>David</div><span><div><div><div><br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Jun 5, 2018 at 12:58 PM, Eric Wieling <span dir="ltr"><<a href="mailto:ewieling@nyigc.com" target="_blank">ewieling@nyigc.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Don't use the _. pattern.  Ever.<br>
<br>
The call has two channels so it needs two hangup handlers, something like this, though I've not tested it.<br>
<br>
[some_context]<br>
exten => _X.,1,Noop<br>
 same => n,Set(CHANNEL(hangup_handler_p<wbr>ush)=my_caller_hangup_handler)<br>
 same => n,Dial(SIP/number@peer,b(pre_d<wbr>ial^s^1))<br>
 same => n,Hangup<br>
<br>
[pre_dial]<br>
exten => s,1,Set(CHANNEL(hangup_handler<wbr>_push)=my_called_hangup_handle<wbr>r)<br>
 same => Return<br>
<br>
See: <a href="https://wiki.asterisk.org/wiki/display/AST/Pre-Dial+Handlers" rel="noreferrer" target="_blank">https://wiki.asterisk.org/wiki<wbr>/display/AST/Pre-Dial+Handlers</a><br>
and <a href="https://wiki.asterisk.org/wiki/display/AST/Hangup+Handlers" rel="noreferrer" target="_blank">https://wiki.asterisk.org/wiki<wbr>/display/AST/Hangup+Handlers</a><span class="m_-8860210534177388803m_-6639619180952909318gmail-"><br>
<br></span></blockquote></div></div></div></div></span></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>