<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=us-ascii">
<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;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        color:black;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman",serif;
        color:black;}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";
        color:black;}
tt
        {mso-style-priority:99;
        font-family:"Courier New";}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:Consolas;
        color:black;}
span.EmailStyle21
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle22
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle23
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle24
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle25
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle26
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle27
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle28
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle29
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle30
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle31
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle32
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle33
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle34
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
span.EmailStyle35
        {mso-style-type:personal;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
span.EmailStyle36
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:#1F497D;}
.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><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body bgcolor="white" lang="EN-US" link="#0563C1" vlink="#954F72">
<div class="WordSection1">
<p class="MsoNormal"><span style="color:blue">Hi Liviu, <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:blue"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:blue">I understand this way. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:blue">When we are getting more calls in opensips, and &nbsp;the TCP port is been open in that particular time window.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:blue">At that time when it tries to send HTTP request, start_async_http_req is called, since is the port is already open, it is assuming that async is completed.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:blue">Am I right?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:blue"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><b><span style="color:blue">most of the call fails</span></b><span style="color:blue"> &#8211; meaning that for first 15 to 20 calls call is successful from end to end.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:blue">After that for the rest of the calls, it fails because
<b>ASYNC_SYNC</b> is returned and hits resume_route. <o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:blue">Here $rc is -4 (ASYNC_SYNC), which is $rc &lt; 0, and am sending 403 Forbidden, due to which other calls are failing.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:blue"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:blue">In the resume function, I have added some logic after getting the HTTP response, what should be done for further handling INVITE request.<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:blue">In these failure calls, &nbsp;it never had a chance to hit the resume function and hence other calls are failing.
<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:blue"><o:p>&nbsp;</o:p></span></p>
<p class="MsoNormal"><span style="color:blue">Regards,<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:blue">Agalya<o:p></o:p></span></p>
<p class="MsoNormal"><span style="color:#1F497D"><o:p>&nbsp;</o:p></span></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="color:windowtext">From:</span></b><span style="color:windowtext"> Liviu Chircu [mailto:liviu@opensips.org]
<br>
<b>Sent:</b> Wednesday, September 14, 2016 4:45 AM<br>
<b>To:</b> Ramachandran, Agalya (Contractor) &lt;Agalya_Ramachandran@comcast.com&gt;; OpenSIPS users mailling list &lt;users@lists.opensips.org&gt;<br>
<b>Subject:</b> Re: [OpenSIPS-Users] FW: Asynchronous operation for REST queries<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p>&nbsp;</o:p></p>
<p><tt><span style="font-size:10.0pt">If you notice that log, then the transfer was completed together with the TCP connect operation, an ideal situation! There is no need to call the resume function anymore, since we already have all the data. As soon as we
 return ASYNC_SYNC, the resume_route will be called.</span></tt><o:p></o:p></p>
<p><tt><span style="font-size:10.0pt">What do you mean by &quot;most of the call fails&quot;? Are you missing any data?</span></tt><o:p></o:p></p>
<pre>Liviu Chircu<o:p></o:p></pre>
<pre>OpenSIPS 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>
<div>
<p class="MsoNormal">On 13.09.2016 21:56, Ramachandran, Agalya (Contractor) wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="color:blue">Hi Liviu, </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">One more observance.&nbsp; Am trying to load test on the main branch where you have provided your fix.
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">Am using REST API as, async. After receiving the response for the HTTP request, I will process the incoming SIP INVITE.
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">If am sending 50 calls at 2 calls per sec from sipp, -in this case it works perfectly fine.
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">If am sending 50 calls at 5 calls per sec from sipp, most of the call fails.
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">If I look at logs I could able to see that for failure case, it hits start_async_http_req, but never resume function is called.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">It is printing </span><span style="color:red">LM_DBG(&quot;done, no need for async!\n&quot;); and returns ASYNC_SYNC;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">Any idea why for few calls, it is not acting as async? Particularly if I increase cps, am seeing this behavior.
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">Please let me know if am missing something.
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">Regards,<br>
Agalya</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D">&nbsp;</span><o:p></o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="color:windowtext">From:</span></b><span style="color:windowtext">
<a href="mailto:users-bounces@lists.opensips.org">users-bounces@lists.opensips.org</a> [<a href="mailto:users-bounces@lists.opensips.org">mailto:users-bounces@lists.opensips.org</a>]
<b>On Behalf Of </b>Ramachandran, Agalya (Contractor)<br>
<b>Sent:</b> Tuesday, September 13, 2016 2:14 PM<br>
<b>To:</b> Liviu Chircu <a href="mailto:liviu@opensips.org">&lt;liviu@opensips.org&gt;</a>; OpenSIPS users mailling list
<a href="mailto:users@lists.opensips.org">&lt;users@lists.opensips.org&gt;</a><br>
<b>Subject:</b> Re: [OpenSIPS-Users] FW: Asynchronous operation for REST queries</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">Hi Liviu, </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">I have configured &#8220;Connection_timeout&#8221; value as &#8216;1&#8217; and ran 2 sipp calls.
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">After TCP port is opened, HTTP request is sent out approx. 95 to 100ms later. Am attaching the log of the opensips by enabling debugging log.
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">I took the code from master branch and tested it out. If you find everything OK let me know.
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">Or if you feel to test any specific scenario please update me, so that I can test and share you the results.
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">P.S:</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">One more observance.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">In the case of synchronous, TCP port is opened within 8 ms, whereas in the case of async TCP port is opening after 100 ms.
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">Is it the expected behavior?.&nbsp; </span>
<o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">What will be expected time to give this fix in a branch version?
</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">Log file ~70 MB if I enable the debug calls for single call and couldn&#8217;t post you that log, since it says limit for email is 40 MB.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">Regards,<br>
Agalya</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D">&nbsp;</span><o:p></o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="color:windowtext">From:</span></b><span style="color:windowtext"> Liviu Chircu [<a href="mailto:liviu@opensips.org">mailto:liviu@opensips.org</a>]
<br>
<b>Sent:</b> Monday, September 12, 2016 4:06 AM<br>
<b>To:</b> OpenSIPS users mailling list &lt;<a href="mailto:users@lists.opensips.org">users@lists.opensips.org</a>&gt;; Ramachandran, Agalya (Contractor) &lt;<a href="mailto:Agalya_Ramachandran@comcast.com">Agalya_Ramachandran@comcast.com</a>&gt;<br>
<b>Subject:</b> Re: FW:[OpenSIPS-Users] Asynchronous operation for REST queries</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
<p><tt><span style="font-size:10.0pt">Hi Agalya,</span></tt><o:p></o:p></p>
<p><tt><span style="font-size:10.0pt">The &quot;connection_timeout&quot; is a configurable module parameter, so tuning it properly might just solve your problem.</span></tt><o:p></o:p></p>
<p><tt><span style="font-size:10.0pt">If you need more assistance, please enable debug logging (log_level = 4), run the query and post the full log output.</span></tt><o:p></o:p></p>
<p><tt><span style="font-size:10.0pt">Best regards,</span></tt><o:p></o:p></p>
<pre>Liviu Chircu<o:p></o:p></pre>
<pre>OpenSIPS 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>
<div>
<p class="MsoNormal">On 09.09.2016 23:04, Ramachandran, Agalya (Contractor) wrote:<o:p></o:p></p>
</div>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="color:blue">Hi Liviu, </span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">I have tested the patch. Now I see the delay is 2 secs. i.e after 2 secs it sends the HTTP request out.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">I suspect this 2000 ms delay is due to the below field:</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:red">long connection_timeout = 20; </span>
<o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">Can we reduce this field to 5 or 10, so that it waits only half a second or second to send the request out.</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">Let me know your thoughts on this. </span>
<o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">Am seeing the below message in logs. Is everything working as you expected?</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:red">rest_client:start_async_http_req: libcurl TCP connect: we should wait up to 1ms (timeout=20000ms)!</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">&nbsp;</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">Regards,</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:blue">Agalya</span><o:p></o:p></p>
<p class="MsoNormal"><span style="color:#1F497D">&nbsp;</span><o:p></o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="color:windowtext">From:</span></b><span style="color:windowtext"> Liviu Chircu [<a href="mailto:liviu@opensips.org">mailto:liviu@opensips.org</a>]
<br>
<b>Sent:</b> Thursday, September 08, 2016 7:05 AM<br>
<b>To:</b> Ramachandran, Agalya (Contractor) <a href="mailto:Agalya_Ramachandran@comcast.com">
&lt;Agalya_Ramachandran@comcast.com&gt;</a>; Bogdan-Andrei Iancu <a href="mailto:bogdan@opensips.org">
&lt;bogdan@opensips.org&gt;</a>; OpenSIPS users mailling list <a href="mailto:users@lists.opensips.org">
&lt;users@lists.opensips.org&gt;</a><br>
<b>Subject:</b> Re: FW:[OpenSIPS-Users] Asynchronous operation for REST queries</span><o:p></o:p></p>
</div>
</div>
<p class="MsoNormal">&nbsp;<o:p></o:p></p>
<p><tt><span style="font-size:10.0pt">Hi, Agalya!</span></tt><o:p></o:p></p>
<p><tt><span style="font-size:10.0pt">Regarding the 10s delay problem, a fix was pushed to the development branch [1]. If you are running on 2.1.4 git branch, could you please pull the latest changes (git pull --rebase), and test it out? You can import it with:</span></tt><o:p></o:p></p>
<p><tt><span style="font-size:10.0pt">git cherry-pick -x&nbsp; 66c337cc</span></tt><o:p></o:p></p>
<p><tt><span style="font-size:10.0pt">[1]: <a href="https://github.com/OpenSIPS/opensips/commit/66c337cc89a2b5c3e1bbd78c289371efcda21886">
https://github.com/OpenSIPS/opensips/commit/66c337cc89a2b5c3e1bbd78c289371efcda21886</a></span></tt><o:p></o:p></p>
<p><tt><span style="font-size:10.0pt">Best regards,</span></tt><o:p></o:p></p>
<pre>Liviu Chircu<o:p></o:p></pre>
<pre>OpenSIPS 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>
</blockquote>
</blockquote>
<p class="MsoNormal"><span style="font-size:12.0pt;font-family:&quot;Times New Roman&quot;,serif"><o:p>&nbsp;</o:p></span></p>
</div>
</body>
</html>