<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<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";}
tt
        {mso-style-priority:99;
        font-family:"Courier New";}
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.EmailStyle23
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;}
span.EmailStyle25
        {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>
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Bogdan,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">That is a good test, but I am not sure what to say. That is not the behavior I am seeing and the acc variable is not being set for me. I am also on 2.4.2.
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">One difference in my case is that it is not a local timeout causing the failure. We are receiving a 481 response from the far end. Perhaps when an actual failure response is received instead of a local timeout the operation is different
 in OpenSIPS?<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 <bogdan@opensips.org><br>
<b>Date: </b>Tuesday, October 2, 2018 at 4:59 AM<br>
<b>To: </b>Ben Newlin <Ben.Newlin@genesys.com>, OpenSIPS users mailling list <users@lists.opensips.org><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""><br>
<br>
<tt>OK, my experiment with 2.4 :</tt><br>
<br>
<tt>* Have a call up between two endpoints</tt><br>
<tt>* kill the end points, without allowing them to send any BYE or so</tt><br>
<tt>* do an dlg_end_dlg from opensips proxy</tt><br>
<br>
<tt>What I got:</tt><br>
<tt>1) the 2 BYE requests are send out, both visiting the local route (where the failure route is armed)</tt><br>
<tt>2) the first BYE ends with internal 408 timeout (based on retransmissions), failure route is triggered (where an extra acc var is set), the dialog transits into TERMINATED state, the acc CDR is generated (holding the value set in failure route)</tt><br>
<tt>3) the second BYE ends also with 408 timeout, the failure route is also triggered (I can see the xlog()), but as the dialog is TERMINATED, there is no impact on the acc level.</tt><br>
<br>
<tt>Regards,</tt><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">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/">http://opensips.org/training/OpenSIPS_Bootcamp_2018/</a><o:p></o:p></pre>
<div>
<p class="MsoNormal">On 09/21/2018 03:07 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">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 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 href="mailto:Ben.Newlin@genesys.com"><Ben.Newlin@genesys.com></a>, OpenSIPS users mailling list
<a href="mailto:users@lists.opensips.org"><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 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>
</span><tt><span style="font-size:10.0pt">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) ?</span></tt><span style="font-size:10.0pt;font-family:"Courier New \,serif""><br>
<br>
</span><tt><span style="font-size:10.0pt">Best regards,</span></tt><span style="font-size:10.0pt;font-family:"Courier New \,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">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/">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"><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">
<users@lists.opensips.org></a>, Ben Newlin <a href="mailto:Ben.Newlin@genesys.com">
<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""><br>
<br>
<tt>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.</tt><br>
<br>
<tt>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.</tt><br>
<br>
<tt>Regards,</tt><br>
<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">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/">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"><users-bounces@lists.opensips.org></a> on behalf of David Villasmil
<a href="mailto:david.villasmil.work@gmail.com"><david.villasmil.work@gmail.com></a><br>
<b>Reply-To: </b>OpenSIPS users mailling list <a 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 href="mailto:users@lists.opensips.org">
<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">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"">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 \,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">Users@lists.opensips.org</a><br>
<a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users" target="_blank">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><o:p></o:p></p>
</blockquote>
</div>
<p class="MsoNormal"><br>
<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">Users@lists.opensips.org</a><o:p></o:p></pre>
<pre><a href="http://lists.opensips.org/cgi-bin/mailman/listinfo/users">http://lists.opensips.org/cgi-bin/mailman/listinfo/users</a><o:p></o:p></pre>
</blockquote>
<p class="MsoNormal"><br>
<br>
<br>
<br>
<o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><br>
<br>
<br>
<o:p></o:p></p>
</blockquote>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
</div>
</body>
</html>