[OpenSIPS-Users] FW: Asynchronous operation for REST queries

Liviu Chircu liviu at opensips.org
Thu Sep 15 09:55:23 CEST 2016


In OpenSIPS script, you can obtain similar results to strtok() with the 
"s.select" string transformation [1].

[1]: http://www.opensips.org/Documentation/Script-Tran-2-3#toc6

Liviu Chircu
OpenSIPS Developer
http://www.opensips-solutions.com

On 14.09.2016 21:57, Ramachandran, Agalya (Contractor) wrote:
>
> Hi Liviu,
>
> I have tested by treating ASYNC_SYNC as success. Now calls are not 
> failing.
>
> When I tried to print the HTTP response which is available in 
> $var(body), I could able to see the payload for HTTP response.
>
> {"status":200,"hasErrors":false,"id":"b991f6c0-790f-11e6-82ef-05ba3d7a5b9d@*test.comcast.net* 
> ","timestamp":1473975975,"messageId":0,"Token":"2de3dbv7823wxcas3fgf"}
>
> I have a question here. When I receive the response in resume function 
> I will do a strtok and extract the domain name “test.comcast.net”.
>
> If am not hitting resume function and it comes directly to 
> resume_route, how the extraction of the domain from the response 
> string can be achieved?
>
> Because regular ‘C’ code and ‘C’ string library won’t work with 
> opensips config file.
>
> Can you please share any documentation you have for extracting 
> particular value from a sting in config file? I see the documentation 
> to form a string but not vice versa.
>
> Regards,
> Agalya.
>
> *From:*Liviu Chircu [mailto:liviu at opensips.org]
> *Sent:* Wednesday, September 14, 2016 12:25 PM
> *To:* Ramachandran, Agalya (Contractor) 
> <Agalya_Ramachandran at comcast.com>; OpenSIPS users mailling list 
> <users at lists.opensips.org>
> *Subject:* Re: [OpenSIPS-Users] FW: Asynchronous operation for REST 
> queries
>
> So you are doing the $rc < 0 check in the beginning of the 
> resume_route? If yes, could you treat ASYNC_SYNC as a success (it 
> actually is!), and see if your output variables are properly populated 
> with the transferred data?
>
> Liviu Chircu
> OpenSIPS Developer
> http://www.opensips-solutions.com
>
> On 14.09.2016 18:58, Ramachandran, Agalya (Contractor) wrote:
>
>     Hi Liviu,
>
>     I understand this way.
>
>     When we are getting more calls in opensips, and  the TCP port is
>     been open in that particular time window.
>
>     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.
>
>     Am I right?
>
>     *most of the call fails*– meaning that for first 15 to 20 calls
>     call is successful from end to end.
>
>     After that for the rest of the calls, it fails because
>     *ASYNC_SYNC* is returned and hits resume_route.
>
>     Here $rc is -4 (ASYNC_SYNC), which is $rc < 0, and am sending 403
>     Forbidden, due to which other calls are failing.
>
>     In the resume function, I have added some logic after getting the
>     HTTP response, what should be done for further handling INVITE
>     request.
>
>     In these failure calls,  it never had a chance to hit the resume
>     function and hence other calls are failing.
>
>     Regards,
>
>     Agalya
>
>     *From:*Liviu Chircu [mailto:liviu at opensips.org]
>     *Sent:* Wednesday, September 14, 2016 4:45 AM
>     *To:* Ramachandran, Agalya (Contractor)
>     <Agalya_Ramachandran at comcast.com>
>     <mailto:Agalya_Ramachandran at comcast.com>; OpenSIPS users mailling
>     list <users at lists.opensips.org> <mailto:users at lists.opensips.org>
>     *Subject:* Re: [OpenSIPS-Users] FW: Asynchronous operation for
>     REST queries
>
>     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.
>
>     What do you mean by "most of the call fails"? Are you missing any
>     data?
>
>     Liviu Chircu
>
>     OpenSIPS Developer
>
>     http://www.opensips-solutions.com
>
>     On 13.09.2016 21:56, Ramachandran, Agalya (Contractor) wrote:
>
>         Hi Liviu,
>
>         One more observance.  Am trying to load test on the main
>         branch where you have provided your fix.
>
>         Am using REST API as, async. After receiving the response for
>         the HTTP request, I will process the incoming SIP INVITE.
>
>         If am sending 50 calls at 2 calls per sec from sipp, -in this
>         case it works perfectly fine.
>
>         If am sending 50 calls at 5 calls per sec from sipp, most of
>         the call fails.
>
>         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.
>
>         It is printing LM_DBG("done, no need for async!\n"); and
>         returns ASYNC_SYNC;
>
>         Any idea why for few calls, it is not acting as async?
>         Particularly if I increase cps, am seeing this behavior.
>
>         Please let me know if am missing something.
>
>         Regards,
>         Agalya
>
>         *From:*users-bounces at lists.opensips.org
>         <mailto:users-bounces at lists.opensips.org>
>         [mailto:users-bounces at lists.opensips.org] *On Behalf Of
>         *Ramachandran, Agalya (Contractor)
>         *Sent:* Tuesday, September 13, 2016 2:14 PM
>         *To:* Liviu Chircu <liviu at opensips.org>
>         <mailto:liviu at opensips.org>; OpenSIPS users mailling list
>         <users at lists.opensips.org> <mailto:users at lists.opensips.org>
>         *Subject:* Re: [OpenSIPS-Users] FW: Asynchronous operation for
>         REST queries
>
>         Hi Liviu,
>
>         I have configured “Connection_timeout” value as ‘1’ and ran 2
>         sipp calls.
>
>         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.
>
>         I took the code from master branch and tested it out. If you
>         find everything OK let me know.
>
>         Or if you feel to test any specific scenario please update me,
>         so that I can test and share you the results.
>
>         P.S:
>
>         One more observance.
>
>         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.
>
>         Is it the expected behavior?.
>
>         What will be expected time to give this fix in a branch version?
>
>         Log file ~70 MB if I enable the debug calls for single call
>         and couldn’t post you that log, since it says limit for email
>         is 40 MB.
>
>         Regards,
>         Agalya
>
>         *From:*Liviu Chircu [mailto:liviu at opensips.org]
>         *Sent:* Monday, September 12, 2016 4:06 AM
>         *To:* OpenSIPS users mailling list <users at lists.opensips.org
>         <mailto:users at lists.opensips.org>>; Ramachandran, Agalya
>         (Contractor) <Agalya_Ramachandran at comcast.com
>         <mailto:Agalya_Ramachandran at comcast.com>>
>         *Subject:* Re: FW:[OpenSIPS-Users] Asynchronous operation for
>         REST queries
>
>         Hi Agalya,
>
>         The "connection_timeout" is a configurable module parameter,
>         so tuning it properly might just solve your problem.
>
>         If you need more assistance, please enable debug logging
>         (log_level = 4), run the query and post the full log output.
>
>         Best regards,
>
>         Liviu Chircu
>
>         OpenSIPS Developer
>
>         http://www.opensips-solutions.com
>
>         On 09.09.2016 23:04, Ramachandran, Agalya (Contractor) wrote:
>
>             Hi Liviu,
>
>             I have tested the patch. Now I see the delay is 2 secs.
>             i.e after 2 secs it sends the HTTP request out.
>
>             I suspect this 2000 ms delay is due to the below field:
>
>             long connection_timeout = 20;
>
>             Can we reduce this field to 5 or 10, so that it waits only
>             half a second or second to send the request out.
>
>             Let me know your thoughts on this.
>
>             Am seeing the below message in logs. Is everything working
>             as you expected?
>
>             rest_client:start_async_http_req: libcurl TCP connect: we
>             should wait up to 1ms (timeout=20000ms)!
>
>             Regards,
>
>             Agalya
>
>             *From:*Liviu Chircu [mailto:liviu at opensips.org]
>             *Sent:* Thursday, September 08, 2016 7:05 AM
>             *To:* Ramachandran, Agalya (Contractor)
>             <Agalya_Ramachandran at comcast.com>
>             <mailto:Agalya_Ramachandran at comcast.com>; Bogdan-Andrei
>             Iancu <bogdan at opensips.org> <mailto:bogdan at opensips.org>;
>             OpenSIPS users mailling list <users at lists.opensips.org>
>             <mailto:users at lists.opensips.org>
>             *Subject:* Re: FW:[OpenSIPS-Users] Asynchronous operation
>             for REST queries
>
>             Hi, Agalya!
>
>             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:
>
>             git cherry-pick -x 66c337cc
>
>             [1]:
>             https://github.com/OpenSIPS/opensips/commit/66c337cc89a2b5c3e1bbd78c289371efcda21886
>
>             Best regards,
>
>             Liviu Chircu
>
>             OpenSIPS Developer
>
>             http://www.opensips-solutions.com
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.opensips.org/pipermail/users/attachments/20160915/2cc17b76/attachment-0001.htm>


More information about the Users mailing list