<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <tt>Hi Ben,<br>
      <br>
      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.<br>
      <br>
      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.<br>
      <br>
      Regards,<br>
    </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/08/2018 01:00 AM, Ben Newlin
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:96D71111-B297-4CDA-9279-E591401A2A35@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;}
/* 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;}
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.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.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">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 class="moz-txt-link-rfc2396E" href="mailto:users-bounces@lists.opensips.org"><users-bounces@lists.opensips.org></a> on behalf of
              David Villasmil <a class="moz-txt-link-rfc2396E" href="mailto:david.villasmil.work@gmail.com"><david.villasmil.work@gmail.com></a><br>
              <b>Reply-To: </b>OpenSIPS users mailling list
              <a class="moz-txt-link-rfc2396E" href="mailto:users@lists.opensips.org"><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 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>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-right:0in">
            <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""> </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"">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"">{</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"">  $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"">}</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""> </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"">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"">{</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"">  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"">}</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""> </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>
      </div>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Users mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Users@lists.opensips.org">Users@lists.opensips.org</a>
<a class="moz-txt-link-freetext" href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>