<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="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${<wbr>IndexIntoPeers}<wbr>CurrentCallsCount)=$[${<wbr>PeerCurrentCallsCount} + 1])</div><div> ; Ensure that hangup by caller/inbound-channel will invoke handleHangupByCaller.</div><div> same => n,Set(CHANNEL(hangup_handler_<wbr>push)=handleHangupByCaller,s,<wbr>1(args))</div><div> same => n,Set(AddressToReachPeer=SIP/$<wbr>{EXTEN:0:4}@${<wbr>PeerBeingConsidered})</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(<wbr>beforeDialingPeerConfigureItsC<wbr>hannelForPeerHangupHandling^s^<wbr>1))</div><div> same => n,Hangup</div><div> </div><div>[<wbr>beforeDialingPeerConfigureItsC<wbr>hannelForPeerHangupHandling]</div><div>exten => s,1,Set(CHANNEL(hangup_<wbr>handler_push)=<wbr>handleHangupByPeer,s,1(args))</div><div> same => n,Return</div><div> </div><div>[handleHangupByPeer]</div><div> ; Ensure that GLOBAL(CB${IndexIntoPeers}<wbr>CurrentCallsCount) is decremented after hangup, and end-of-call-epoch is set.</div><div>exten => s,1,NoOp(${<wbr>PeerBeingConsidered} peer channel: Entered handleHangupByCallerOrPeer Calls ${CB${IndexIntoPeers}<wbr>CurrentCallsCount})</div><div> same => n,Set(GLOBAL(CB${<wbr>IndexIntoPeers}<wbr>CurrentCallsCount)=$[${CB${<wbr>IndexIntoPeers}<wbr>CurrentCallsCount} - 1])</div><span class=""><div> same => n,Set(GLOBAL(${<wbr>PeerBeingConsidered}<wbr>EpochAtCallEnd)=${EPOCH})</div><div> same => n,Return</div><div> </div></span><div>[handleHangupByCaller]</div><div> ; Ensure that GLOBAL(CB${IndexIntoPeers}<wbr>CurrentCallsCount) is decremented after hangup, and end-of-call-epoch is set.</div><div>exten => s,1,NoOp(${<wbr>PeerBeingConsidered} caller channel: Entered handleHangupByCallerOrPeer Calls ${CB${IndexIntoPeers}<wbr>CurrentCallsCount})</div><div> same => n,Set(GLOBAL(CB${<wbr>IndexIntoPeers}<wbr>CurrentCallsCount)=$[${CB${<wbr>IndexIntoPeers}<wbr>CurrentCallsCount} - 1])</div><span class=""><div> same => n,Set(GLOBAL(${<wbr>PeerBeingConsidered}<wbr>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}<wbr>CurrentCallsCount 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 class=""><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_-6639619180952909318gmail-"><br>
<br></span></blockquote></div></div></div></div></span></div></div>
</blockquote></div><br></div>