<div dir="ltr">Seems I hit this: <a href="https://issues.asterisk.org/jira/browse/ASTERISK-23133">https://issues.asterisk.org/jira/browse/ASTERISK-23133</a> </div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 27, 2017 at 5:03 AM, Dovid Bender <span dir="ltr"><<a href="mailto:dovid@telecurve.com" target="_blank">dovid@telecurve.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">My issue seems to be that I am using local channels. So for instance if I have:<div><br></div><div><div>[incoming]</div><div>Exten => _X.,1,NooP()</div><div>Exten => _X.,n,Dial(Local/${EXTEN}@out1<wbr>/n)</div><div>Exten => _X.,n,Dial(Local/${EXTEN}@out2<wbr>/n)</div><div><br></div><div>Exten => h,1,DumpChan()</div><div><br></div><div><br></div><div>[out1]</div><span class=""><div>exten => _X.,1,Noop</div><div> same => n,Set(MASTER_CHANNEL(start_<wbr>timestamp)=${STRFTIME(,,%s.%<wbr>3q)})</div><div> same => n,Set(CHANNEL(hangup_handler_<wbr>push)=hangup_handler,s,1)</div><div> same => n,Set(MASTER_CHANNEL(callid_<wbr>ingress)=${SIPCALLID})</div></span><div> same => n,Dial(SIP/1111${<a href="http://EXTEN%7D@1.1.1.1:5063" target="_blank">EXTEN}@1.1.1.<wbr>1:5063</a>,,U(answer_handler)b(<wbr>pre_dial_handler^s^1))</div><div><br></div><div>Exten => h,1,DumpChan()</div><div>[out2]</div><span class=""><div>exten => _X.,1,Noop</div><div> same => n,Set(MASTER_CHANNEL(start_<wbr>timestamp)=${STRFTIME(,,%s.%<wbr>3q)})</div><div> same => n,Set(CHANNEL(hangup_handler_<wbr>push)=hangup_handler,s,1)</div><div> same => n,Set(MASTER_CHANNEL(callid_<wbr>ingress)=${SIPCALLID})</div></span><div> same => n,Dial(SIP/2222${<a href="http://EXTEN%7D@1.1.1.1:5063" target="_blank">EXTEN}@1.1.1.<wbr>1:5063</a>,,U(answer_handler)b(<wbr>pre_dial_handler^s^1))</div><div><br></div><div>Exten => h,1,DumpChan()</div><span class=""><div><br></div><div>[pre_dial_handler] ; this is called on the outgoing (callee) channel</div><div>exten => s,1,Noop</div><div> same => n,Set(MASTER_CHANNEL(callid_<wbr>egress)=${SIPCALLID})</div><div> same => n,Set(MASTER_CHANNEL(dial_<wbr>timestamp)=${STRFTIME(,,%s.%<wbr>3q)})</div><div> same => n,Return</div><div><br></div><div><br></div><div>[answer_handler] ; run on outgoing (callee) channel, but sets answer_timestamp in the caller channel</div><div>exten => s,1,Noop</div><div> same => n,Set(MASTER_CHANNEL(answer_<wbr>timestamp)=${STRFTIME(,,%s.%<wbr>3q)})</div><div> same => n,Return</div><div><br></div><div><br></div><div>[hangup_handler]  ; run on incoming (caller) channel, use to do final post call cleanup</div><div>exten => s,1,Noop</div><div>  same => n,Set(MASTER_CHANNEL(hangup_<wbr>timestamp)=${STRFTIME(,,%s.%<wbr>3q)})</div></span><div>  same => n,Return</div><div><br></div><div><br></div></div><div><br></div><div><br></div><div>When using MASTER_CHANNEL it sets it on the channel that created the local channel (so it ends up in context incoming and NOT in out1). Not sure if this is a bug since the context incoming is generating the channel that calls out1 that then calls the answer_handler.</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 27, 2017 at 4:50 AM, Dovid Bender <span dir="ltr"><<a href="mailto:dovid@telecurve.com" target="_blank">dovid@telecurve.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">It seems that what ever I set in my answer handler does not show up in the hangup handler. In order to do billing I can't rely on the g option where the caller hangs up the call. Looks like I can either use h or a hangup handler along with the shared function.<div><br></div><div><br></div></div><div class="m_-5921625027053872357HOEnZb"><div class="m_-5921625027053872357h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 26, 2017 at 4:40 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <tt>Don't use an 'h' extension, use a hangup handler.   </tt><tt><br>
    </tt><tt>Use the MASTER_CHANNEL() function to set variables to
      ensure they are always set in the "top most" channel.  Below is an
      untested example, but is inspired by dialplan code I use in
      production.  Maybe it will help.<br>
      <br>
    </tt>
    <div><tt>[outbound] ; this is called on the incoming (caller)
        channel</tt><tt><br>
      </tt></div>
    <div><tt>exten => _X.,1,Noop</tt><tt><br>
      </tt><tt> same =>
        n,Set(MASTER_CHANNEL(start_tim<wbr>estamp)=${STRFTIME(,,%s.%3q)})</tt><tt><br>
      </tt><tt> same =>
        n,Set(CHANNEL(hangup_handler_p<wbr>ush)=hangup_handler,s,1)</tt><tt><br>
      </tt><tt><tt> same =>
          n,Set(MASTER_CHANNEL(callid_in<wbr>gress)=${SIPCALLID})</tt><tt><br>
           </tt>same => n, *** unrelated dialplan, AGIs, etc. ***</tt><tt><br>
      </tt><tt> same => n,Dial(SIP/${</tt><tt><a href="mailto:EXTEN%7D@1.1.1.1" target="_blank">EXTEN}@1.1.1.1</a></tt><tt>,,U<wbr>(answer_handler)b(pre_dial_han<wbr>dler^s^1)g</tt><tt><br>
      </tt><tt> same => n, *** dialplan for the caller when the
        callee hangs up first, not run when caller hangs up first.  use
        it to try dialing another destination, play intercept to caller,
        etc. ***</tt><tt><br>
      </tt><tt><br>
      </tt><tt><br>
      </tt><tt>[pre_dial_handler] ; this is called on the outgoing
        (callee) channel</tt><tt><br>
      </tt><tt>exten => s,1,Noop</tt><tt><br>
      </tt><tt> same =>
        n,Set(MASTER_CHANNEL(callid_eg<wbr>ress)=${SIPCALLID})</tt><tt><br>
      </tt><tt> same =>
        n,Set(MASTER_CHANNEL(dial_time<wbr>stamp)=${STRFTIME(,,%s.%3q)})</tt><tt><br>
      </tt><tt> same => n,Return</tt><tt><br>
      </tt><tt><br>
      </tt><tt><br>
      </tt><tt>[answer_handler] ; run on outgoing (callee) channel, but
        sets answer_timestamp in the caller channel</tt><tt><br>
      </tt><tt>exten => s,1,Noop</tt><tt><br>
      </tt><tt> same =>
        n,Set(MASTER_CHANNEL(answer_ti<wbr>mestamp)=${STRFTIME(,,%s.%3q)}<wbr>)</tt><tt><br>
      </tt><tt> same => n,Return</tt><tt><br>
      </tt><tt><br>
      </tt><tt><br>
      </tt><tt>[hangup_handler]  ; run on incoming (caller) channel, use
        to do final post call cleanup </tt><tt><br>
      </tt><tt>
        exten => s,1,Noop</tt><tt><br>
      </tt><tt>
         
        same =>
        n,Set(MASTER_CHANNEL(hangup_ti<wbr>mestamp)=${STRFTIME(,,%s.%3q)}<wbr>)</tt><tt><br>
      </tt><tt>  same => n, ***post call cleanup AGIs, dialplan, etc.</tt><tt>
        ***<br>
      </tt><tt> 
        same => n,Return</tt><tt><br>
      </tt><tt> </tt><tt><br>
      </tt><br>
      <br>
    </div><div><div class="m_-5921625027053872357m_2477324455072723909h5">
    <div class="m_-5921625027053872357m_2477324455072723909m_-3585907076439800804moz-cite-prefix">On 12/26/2017 03:28 PM, Dovid Bender
      wrote:<br>
    </div>
    <blockquote type="cite">
      <div dir="ltr">Hi,
        <div><br>
        </div>
        <div>I have a dial plan where I need to notify an external
          system when a call was answered and when the call hung up. In
          both requests the start time needs to be the same. My Dialplan
          looks something like this:</div>
        <div><br>
        </div>
        <div><br>
        </div>
        <div>[outbound]</div>
        <div>Exten => _X.,1,Dial(SIP/${<a href="mailto:EXTEN%7D@1.1.1.1" target="_blank">EXTEN}@1.1.1.<wbr>1</a>,,U(call-answer-from-carrier)<wbr>)</div>
        <div><br>
        </div>
        <div>Exten => h,1,NoOp(ANSWERED_TIME: ${ANSWEREDTIME}
          >>> DIAL_TIME: ${DIALEDTIME} >>>
          HANGUP_TIME: ${EPOCH} >>> ANSWERED TIME
          ${MATH(${EPOCH}-${ANSWEREDTIME<wbr>},int)})</div>
        <div><br>
        </div>
        <div>[call-answer-from-carrier]</div>
        <div>Exten => s,1,Noop(CALL WAS ANSWERED AT ${EPOCH}</div>
        <div>Exten => s,n,Agi(some_script.py)</div>
        <div><br>
        </div>
        <div>Now in theory the hangup time of the call (${EPOCH} in the
          h extension) minus the answered time should be the same as the
          noop from my subroutine. I am finding that some times they
          match and some times they are off by a second. My issue is
          that the external system expects the answered time to the same
          for when we call it from the SubRoutine as well as from the h
          extension. I assume the difference is based on the microsecond
          of when we look at EPOCH how DIALEDTIME is rounded.</div>
        <div><br>
        </div>
        <div>Any tips on how I can get the same answered time across the
          board?</div>
        <div><br>
        </div>
        <div>TIA.</div>
        <div><br>
        </div>
        <div>Dovid</div>
        <div><br>
        </div>
      </div>
      <br>
      <fieldset class="m_-5921625027053872357m_2477324455072723909m_-3585907076439800804mimeAttachmentHeader"></fieldset>
      <br>
    </blockquote>
    <br>
  </div></div></div>

</blockquote></div><br></div>
</div></div></blockquote></div><br></div>
</div></div></blockquote></div><br></div>