[SR-Users] Query with regard to http_client and http_async_client

Giacomo Vacca giacomo.vacca at gmail.com
Wed Apr 26 22:39:00 CEST 2017


I have updated the http_async_client documentation for master and 5.0.

Please note that in respect to 4.4 http_async_query() now only takes 2
parameters: the payload is passed with $http_req(body).

Giacomo

On 25 April 2017 at 22:09, Giacomo Vacca <giacomo.vacca at gmail.com> wrote:

> Hi,
> reusing the same connection to the same url is delegated to liburl, so you
> can have that when using http_async_client.
> More workers will increase the capacity at the price of resources (shared
> memory).
> I wrote a wrap up about building the request payload here:
> https://lists.kamailio.org/pipermail/sr-users/2016-December/095454.html -
> please double check escaping.
> The function methods have been reviewed in version 5 and removed, replaced
> by pseudovariable settings which is more common practice in kamailio.
> Instead of http_append_header() use
> $http_req(hdr) = "X-theheader: the value";
>
> Instead of http_set_method() use
> $http_req(method) = "POST";
>
> The latest documentation requires a little review for some mentions of the
> old functions. Will try to fix as soon as possible.
>
> Best Regards,
> Giacomo
>
> On 25 April 2017 at 19:02, Pranathi Venkatayogi <pvenkatayogi at cyracom.com>
> wrote:
>
>> I recently successfully used http_async_client for POST. Will try to help
>> you out here -
>>
>>
>>
>> *From:* sr-users [mailto:sr-users-bounces at lists.kamailio.org] *On Behalf
>> Of *Ramachandran, Agalya (Contractor)
>> *Sent:* Tuesday, April 25, 2017 10:17 AM
>> *To:* giacomo.vacca at gmail.com; sr-users at lists.kamailio.org
>> *Subject:* [SR-Users] Query with regard to http_client and
>> http_async_client
>>
>>
>>
>> Hi Giacomo,
>>
>>
>>
>> I have few questions with regard to rest client in kamailio.
>>
>>
>>
>> 1)     I see there are two modules in kamailio for rest client.
>> http_client, http_async_client.
>>
>> I hope http_client does the http transfer in synchronous  way.
>>
>> http_async_client does the http transfer in asynchronous manner.
>>
>> Correct me if am wrong here.
>>
>> Correct.
>>
>> 2)     I want to achieve https transfers in async way, so choosing
>> http_async_client.
>>
>> Is there a way that kamailio *maintains persistent TCP connection
>>  pooling for http transfer*.
>>
>> I see there is a “workers” parameter in http_async_client. By increasing
>> this number does it result it more http request’s handling?
>>
>> Let the author reply here.
>>
>> 3)     Also, I have some questions regarding documentation for module
>> http_async_client in 5.0 version.
>>
>> In the API exposure, it says *“http_async_query(url, route_name)”*.
>>
>> But the example if I want to use *POST*, it says *“http_async_query("http://example.com/test.php
>> <http://example.com/test.php>", "{'r_uri':'$rU', 'f_uri':'$fU'}",
>> "HTTP_REPLY");”*
>>
>> There is a parameter mismatch between the example and the actual
>> function.
>>
>>
>>
>> If I try to use *GET* query, kamailio service is starting. But if I try
>> to give the *POST* query with payload, kamailio service is not started.
>>
>> It says, sctp_core_destroy(): SCTP API not initialized.
>>
>>
>>
>> Also I have noticed that, functions like http_append_header(),http_set_method()
>> are removed in 5.0 version, whereas we have this API’s is 4.x versions.
>>
>> Is there some issue with the documentation for 5.0  ?
>>
>>
>>
>> I used it like this and it works - http_async_query("http://TEXT_
>> BROKER/api/events/CallAnswered",
>>
>>                  "{'CallId':'$ci', 'Time' : '$TF'}",
>>
>>  "HTTP_REPLY");
>>
>> Issue may be with quotes. Make sure you don’t have “ in the second
>> parameter content. If you send Kamailio log it will be easier to debug.
>>
>>
>>
>> Please let me the know the details for the above queries.
>>
>>
>>
>> Regards,
>> Agalya
>>
>>
>>
>>
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20170426/7e270233/attachment.html>


More information about the sr-users mailing list