<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <tt>Hi Ben,<br>
      <br>
      <tt>OK, my experiment<tt> with 2.4 :<br>
          <br>
          <tt>* Ha<tt>ve a call <tt>up between two endpoints</tt></tt></tt><br>
          <tt>* kill the <tt>end points, w<tt>ithout allowing them to
                send any BYE or so<br>
                <tt>* do an<tt> dlg_end_dl<tt>g from opensips proxy<br>
                      <br>
                      <tt>What I <tt>got:<br>
                          <tt><tt>1) the <tt>2 BYE requests are send
                                out, b<tt>oth visiting the local route
                                  (where the failure route is armed)<br>
                                  <tt>2) the first BYE ends with <tt>internal
                                      <tt>408 timeout (based on <tt>re<tt>transmissions),
                                            failure route is triggered
                                            (where an ex<tt>tra <tt>acc
                                                var is set), the dialog
                                                tran<tt>sits into
                                                  TERMINATED state, the
                                                  acc CDR is ge<tt>nerated
                                                    (<tt>holding the
                                                      value set in
                                                      failure route)<br>
                                                      <tt>3) <tt>the
                                                          seco<tt>nd BYE
                                                          ends also w<tt>ith
                                                          408 timeout,
                                                          the fai<tt>lure
                                                          route is al<tt>so<tt>
                                                          trigger<tt>ed
                                                          (<tt>I can see
                                                          the xlog()),
                                                          but as the
                                                          dialog is <tt>TERMINATED,
                                                          th<tt>ere is
                                                          no impact on
                                                          the acc<tt>
                                                          level.<br>
                                                          <br>
                                                          <tt>Regards,</tt><br>
                                                          </tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt></tt><br>
        </tt></tt></tt>
    <pre class="moz-signature" cols="72">Bogdan-Andrei Iancu

OpenSIPS Founder and Developer
  <a class="moz-txt-link-freetext" href="http://www.opensips-solutions.com">http://www.opensips-solutions.com</a>
OpenSIPS Bootcamp 2018
  <a class="moz-txt-link-freetext" href="http://opensips.org/training/OpenSIPS_Bootcamp_2018/">http://opensips.org/training/OpenSIPS_Bootcamp_2018/</a>
</pre>
    <div class="moz-cite-prefix">On 09/21/2018 03:07 PM, Ben Newlin
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:E02AEE04-8B95-423B-BE81-EB2C7E724BE2@genesys.com">
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
      <meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
      <style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
@font-face
        {font-family:"Courier New \,serif";
        panose-1:2 7 3 9 2 2 5 2 4 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New",serif;}
tt
        {mso-style-priority:99;
        font-family:"Courier New",serif;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;}
span.EmailStyle22
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;}
span.EmailStyle24
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style>
      <div class="WordSection1">
        <p class="MsoNormal">Bogdan,<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal">Yes, as per the script example I provided
          originally I am arming failure_route always in local_route and
          setting the acc_extra variable in failure_route. Even in the
          case where the first BYE response is a failure, the acc_extra
          variable is not being set. This seems to indicate the dialog
          is being terminated prior to the call to the failure route.<o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <p class="MsoNormal"><span style="color:black">Ben Newlin </span><o:p></o:p></p>
        <p class="MsoNormal"><o:p> </o:p></p>
        <div style="border:none;border-top:solid #B5C4DF
          1.0pt;padding:3.0pt 0in 0in 0in">
          <p class="MsoNormal"><b><span
                style="font-size:12.0pt;color:black">From: </span></b><span
              style="font-size:12.0pt;color:black">Bogdan-Andrei Iancu
              <a class="moz-txt-link-rfc2396E" href="mailto:bogdan@opensips.org"><bogdan@opensips.org></a><br>
              <b>Date: </b>Friday, September 21, 2018 at 5:31 AM<br>
              <b>To: </b>Ben Newlin <a class="moz-txt-link-rfc2396E" href="mailto:Ben.Newlin@genesys.com"><Ben.Newlin@genesys.com></a>,
              OpenSIPS users mailling list
              <a class="moz-txt-link-rfc2396E" href="mailto:users@lists.opensips.org"><users@lists.opensips.org></a><br>
              <b>Subject: </b>Re: [OpenSIPS-Users] Accounting BYE
              response<o:p></o:p></span></p>
        </div>
        <div>
          <p class="MsoNormal"><o:p> </o:p></p>
        </div>
        <p class="MsoNormal"><tt><span style="font-size:10.0pt">Hi Ben,</span></tt><span
            style="font-size:10.0pt;font-family:"Courier
            New",serif"><br>
            <br>
            <tt>The Dialog is not terminated (as status) with the first
              successful BYE reply, but with the first reply (whatever
              the status is). Even if both caller and callee BYE will
              turn into 408 or 481, the first to fire will terminate the
              dialog session. But you say that if failure_route is
              triggered for both BYEs, you still see no acc extra data
              (even if at first one should have been executed before
              dialog termination) ?</tt><br>
            <br>
            <tt>Best regards,</tt><br>
            <br>
          </span><o:p></o:p></p>
        <pre>Bogdan-Andrei Iancu<o:p></o:p></pre>
        <pre><o:p> </o:p></pre>
        <pre>OpenSIPS Founder and Developer<o:p></o:p></pre>
        <pre>  <a href="http://www.opensips-solutions.com" moz-do-not-send="true">http://www.opensips-solutions.com</a><o:p></o:p></pre>
        <pre>OpenSIPS Bootcamp 2018<o:p></o:p></pre>
        <pre>  <a href="http://opensips.org/training/OpenSIPS_Bootcamp_2018/" moz-do-not-send="true">http://opensips.org/training/OpenSIPS_Bootcamp_2018/</a><o:p></o:p></pre>
        <div>
          <p class="MsoNormal">On 09/20/2018 06:57 PM, Ben Newlin wrote:<o:p></o:p></p>
        </div>
        <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
          <p class="MsoNormal">Bogdan,<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">This is a good point and I did consider
            that. However, this only makes sense in the case where there
            is a successful response prior to the error response. As I
            noted I have seen this occur when both parties reply to the
            BYE with a 481 response. If the Dialog and ACC modules were
            triggering on the first BYE reply received, then my flag
            should still be getting set in this case as the first reply
            is guaranteed to be a failure.<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal">Is it possible the dialog termination and
            CDR generation are being triggered prior to the
            failure_route callback? If so, are they also triggered prior
            to a reply_route callback? Would it make sense to delay the
            dialog termination until after failure_route processing to
            allow the script to make final adjustments to the CDR such
            as this?<o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <p class="MsoNormal"><span style="color:black">Ben Newlin </span><o:p></o:p></p>
          <p class="MsoNormal"> <o:p></o:p></p>
          <div style="border:none;border-top:solid #B5C4DF
            1.0pt;padding:3.0pt 0in 0in 0in">
            <p class="MsoNormal"><b><span
                  style="font-size:12.0pt;color:black">From: </span></b><span
                style="font-size:12.0pt;color:black">Bogdan-Andrei Iancu
                <a href="mailto:bogdan@opensips.org"
                  moz-do-not-send="true"><bogdan@opensips.org></a><br>
                <b>Date: </b>Thursday, September 20, 2018 at 11:42 AM<br>
                <b>To: </b>OpenSIPS users mailling list <a
                  href="mailto:users@lists.opensips.org"
                  moz-do-not-send="true">
                  <users@lists.opensips.org></a>, Ben Newlin <a
                  href="mailto:Ben.Newlin@genesys.com"
                  moz-do-not-send="true">
                  <Ben.Newlin@genesys.com></a><br>
                <b>Subject: </b>Re: [OpenSIPS-Users] Accounting BYE
                response</span><o:p></o:p></p>
          </div>
          <div>
            <p class="MsoNormal"> <o:p></o:p></p>
          </div>
          <p class="MsoNormal"><tt><span style="font-size:10.0pt">Hi
                Ben,</span></tt><span
              style="font-size:10.0pt;font-family:"Courier New
              ,serif",serif"><br>
              <br>
            </span><tt><span style="font-size:10.0pt">The issue is a bit
                more complex. When generating the BYE requests, the
                dialog module triggers the event of call terminated when
                it gets back the first final reply (to any of the BYEs).
                And ACC module generates the CDR when the dialog is
                terminated.</span></tt><span
              style="font-size:10.0pt;font-family:"Courier New
              ,serif",serif"><br>
              <br>
            </span><tt><span style="font-size:10.0pt">So, the second BYE
                (which probably ends with timeout) ends in failure route
                (and set the acc extra) *after* the call was terminated
                and the CDR generated.</span></tt><span
              style="font-size:10.0pt;font-family:"Courier New
              ,serif",serif"><br>
              <br>
            </span><tt><span style="font-size:10.0pt">Regards,</span></tt><span
              style="font-size:10.0pt;font-family:"Courier New
              ,serif",serif"><br>
              <br>
              <br>
            </span><o:p></o:p></p>
          <pre>Bogdan-Andrei Iancu<o:p></o:p></pre>
          <pre> <o:p></o:p></pre>
          <pre>OpenSIPS Founder and Developer<o:p></o:p></pre>
          <pre>  <a href="http://www.opensips-solutions.com" moz-do-not-send="true">http://www.opensips-solutions.com</a><o:p></o:p></pre>
          <pre>OpenSIPS Bootcamp 2018<o:p></o:p></pre>
          <pre>  <a href="http://opensips.org/training/OpenSIPS_Bootcamp_2018/" moz-do-not-send="true">http://opensips.org/training/OpenSIPS_Bootcamp_2018/</a><o:p></o:p></pre>
          <div>
            <p class="MsoNormal">On 09/08/2018 01:00 AM, Ben Newlin
              wrote:<o:p></o:p></p>
          </div>
          <blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
            <p class="MsoNormal">David,<o:p></o:p></p>
            <p class="MsoNormal"> <o:p></o:p></p>
            <p class="MsoNormal">I agree that there are better ways to
              do billing, but I must work within the constraints of the
              larger system of which I am only a part.<o:p></o:p></p>
            <p class="MsoNormal"> <o:p></o:p></p>
            <p class="MsoNormal">We do use some other techniques to
              detect “stuck” calls, including the (fairly) new Re-Invite
              pinging mechanism of the dialog module. We do not process
              the audio, so silence detection is not possible.<o:p></o:p></p>
            <p class="MsoNormal"> <o:p></o:p></p>
            <p class="MsoNormal">It is a very small number of calls that
              are affected by this, hopefully none now that we have the
              pinging in place, but I am still interested in the answer
              to the question. It seems to me there could be other use
              cases for modifying the CDR based on the response to a
              BYE, whether generated from OpenSIPS or not.<o:p></o:p></p>
            <p class="MsoNormal"> <o:p></o:p></p>
            <p class="MsoNormal"><span style="color:black">Ben Newlin </span><o:p></o:p></p>
            <p class="MsoNormal"> <o:p></o:p></p>
            <div style="border:none;border-top:solid #B5C4DF
              1.0pt;padding:3.0pt 0in 0in 0in">
              <p class="MsoNormal"><b><span
                    style="font-size:12.0pt;color:black">From: </span></b><span
                  style="font-size:12.0pt;color:black">Users
                  <a href="mailto:users-bounces@lists.opensips.org"
                    moz-do-not-send="true"><users-bounces@lists.opensips.org></a>
                  on behalf of David Villasmil
                  <a href="mailto:david.villasmil.work@gmail.com"
                    moz-do-not-send="true"><david.villasmil.work@gmail.com></a><br>
                  <b>Reply-To: </b>OpenSIPS users mailling list <a
                    href="mailto:users@lists.opensips.org"
                    moz-do-not-send="true">
                    <users@lists.opensips.org></a><br>
                  <b>Date: </b>Friday, September 7, 2018 at 5:53 PM<br>
                  <b>To: </b>OpenSIPS users mailling list <a
                    href="mailto:users@lists.opensips.org"
                    moz-do-not-send="true">
                    <users@lists.opensips.org></a><br>
                  <b>Subject: </b>Re: [OpenSIPS-Users] Accounting BYE
                  response</span><o:p></o:p></p>
            </div>
            <div>
              <p class="MsoNormal"> <o:p></o:p></p>
            </div>
            <p>I think you should take care of this on your gateway. For
              example, using freeswitch or asterisk, you can check for
              rtps, and when the other end stops sending rtps for 30
              seconds (configurable) it will tear down the call
              properly.
              <o:p></o:p></p>
            <p>Unless you're using a rtp-proxy with opensips which can
              do this (most can), that's the way to do this. Anything
              else is just duct-taping.<o:p></o:p></p>
            <p>My opinion after 20 years on voip.<o:p></o:p></p>
            <p>Hope that helps.<o:p></o:p></p>
            <p>David<o:p></o:p></p>
            <p class="MsoNormal"> <o:p></o:p></p>
            <div>
              <div>
                <p class="MsoNormal">On Fri, Sep 7, 2018, 21:43 Ben
                  Newlin <<a href="mailto:Ben.Newlin@genesys.com"
                    moz-do-not-send="true">Ben.Newlin@genesys.com</a>>
                  wrote:<o:p></o:p></p>
              </div>
              <blockquote style="border:none;border-left:solid #CCCCCC
                1.0pt;padding:0in 0in 0in
6.0pt;margin-left:4.8pt;margin-top:5.0pt;margin-right:0in;margin-bottom:5.0pt">
                <div>
                  <div>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">Hi,<o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">I
                      am having an issue trying to add values to
                      accounting based on the response to the BYE
                      request.<o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">We
                      use the dialog timeout mechanism to terminate long
                      calls in our system. In some cases, these are
                      “valid” calls that remained connected for too long
                      due to some error elsewhere in the application.
                      But sometimes one or both ends of the call believe
                      they have disconnected, but we did not receive or
                      process the disconnect, due to a malformed BYE or
                      a network disruption. In these cases, when the
                      Dialog timeout is reached and OpenSIPS generates a
                      BYE to both parties, they will respond with a 481.<o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">What
                      I want is to set a CDR flag on receipt of that 481
                      to indicate that there was an error and the
                      calculated call time may not be correct. But it
                      seems that any accounting flags set after the BYE
                      is sent are not honored. Is there any way to
                      accomplish this?<o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"> <o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto">This
                      is my attempt:<o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
                        style="font-family:"Courier
                        New",serif"> </span><o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:10.0pt;font-family:"Courier New
                        ,serif",serif">failure_route[local_failure]</span><o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:10.0pt;font-family:"Courier New
                        ,serif",serif">{</span><o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:10.0pt;font-family:"Courier New
                        ,serif",serif"> 
                        $acc_extra(disconnect_error) = "true";</span><o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:10.0pt;font-family:"Courier New
                        ,serif",serif">}</span><o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:10.0pt;font-family:"Courier New
                        ,serif",serif"> </span><o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:10.0pt;font-family:"Courier New
                        ,serif",serif">local_route</span><o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:10.0pt;font-family:"Courier New
                        ,serif",serif">{</span><o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:10.0pt;font-family:"Courier New
                        ,serif",serif"> 
                        t_on_failure("local_failure");</span><o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
style="font-size:10.0pt;font-family:"Courier New
                        ,serif",serif">}</span><o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
                        style="font-family:"Courier
                        New",serif"> </span><o:p></o:p></p>
                    <p class="MsoNormal"
                      style="mso-margin-top-alt:auto;mso-margin-bottom-alt:auto"><span
                        style="color:black">Ben Newlin
                      </span><o:p></o:p></p>
                  </div>
                </div>
                <p class="MsoNormal">_______________________________________________<br>
                  Users mailing list<br>
                  <a href="mailto:Users@lists.opensips.org"
                    target="_blank" moz-do-not-send="true">Users@lists.opensips.org</a><br>
                  <a
                    href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users"
                    target="_blank" moz-do-not-send="true">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><o:p></o:p></p>
              </blockquote>
            </div>
            <p class="MsoNormal"><br>
              <br>
              <br>
              <br>
              <o:p></o:p></p>
            <pre>_______________________________________________<o:p></o:p></pre>
            <pre>Users mailing list<o:p></o:p></pre>
            <pre><a href="mailto:Users@lists.opensips.org" moz-do-not-send="true">Users@lists.opensips.org</a><o:p></o:p></pre>
            <pre><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" moz-do-not-send="true">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><o:p></o:p></pre>
          </blockquote>
          <p class="MsoNormal"><br>
            <br>
            <br>
            <o:p></o:p></p>
        </blockquote>
        <p class="MsoNormal"><br>
          <br>
          <o:p></o:p></p>
      </div>
    </blockquote>
    <br>
  </body>
</html>