[SR-Users] Http_async_client stops script execution

Denys Pozniak denys.pozniak at gmail.com
Thu Sep 27 17:00:49 CEST 2018


This example does not work. I do not see log message.

*Example 1.13. http_async_suspend() usage*

...
t_newtran();
http_async_suspend(0);
# the transaction won't be suspended for the next query
http_async_query("http://example.com/test.php", "HTTP_REPLY");
xlog("L_INFO", "query sent\n");
t_reply("200", "Ok");

...




2018-09-27 17:54 GMT+03:00 Federico Cabiddu <federico.cabiddu at gmail.com>:

> What do you mean with "does not work well "?
> I don't remember any change in that part but anyway you should switch to
> 5.0 or 5.1 releases, since those are the maintained ones.
>
> Best regards,
>
> Federico
>
> On Thu, Sep 27, 2018 at 4:50 PM Denys Pozniak <denys.pozniak at gmail.com>
> wrote:
>
>> Looks like http_async_suspend(0); does not work well in v4.4.2.
>>
>> https://www.kamailio.org/docs/modules/4.4.x/modules/http_
>> async_client.html#http_async_client.f.http_async_suspend
>>
>> 2018-09-27 17:40 GMT+03:00 Denys Pozniak <denys.pozniak at gmail.com>:
>>
>>> So my config is ok and I need to add all next logic with call routing to route[HTTP_REPLY]
>>> ,correct ?
>>>
>>>
>>>
>>> 2018-09-27 16:42 GMT+03:00 Federico Cabiddu <federico.cabiddu at gmail.com>
>>> :
>>>
>>>> Hi,
>>>> if you are in a transactional contest (as you are since you are calling
>>>> t_newtran()), the script execution is suspended, upon calling
>>>> http_async_query and resumed in the callback route passed as parameter.
>>>> The instructions after the call to http_async_query are never executed.
>>>> If you are not in a transactional contest or you explicitly instruct to not
>>>> suspend the transaction ($http(suspend) = 0, http://www.kamailio.org/
>>>> docs/modules/devel/modules/http_async_client.html#idm1053320700) they
>>>> will be executed, and the callback route will be run when the http reply
>>>> comes. If you want to use http uqeries to retrieve parameters you want to
>>>> use for your routing logic, you need to suspend the transaction and resume
>>>> it in the callback.
>>>> Hope this clarify.
>>>>
>>>> Best regards,
>>>>
>>>> Federico
>>>>
>>>> On Thu, Sep 27, 2018 at 3:36 PM Denys Pozniak <denys.pozniak at gmail.com>
>>>> wrote:
>>>>
>>>>> Hello!
>>>>>
>>>>> Please help me to understand how http_async_client module behaves. I
>>>>> am going to use it for call routing according to the http response.
>>>>>
>>>>> if (is_method("INVITE")) {
>>>>>         t_newtran();
>>>>>         xlog("L_ERR", "ASYNC0-$fU-$rU-$rm---- \n");
>>>>>         http_set_timeout(1000);
>>>>>         http_set_method("POST");
>>>>>         http_append_header("Content-Type: application/json");
>>>>>         http_async_query("http://10.10.10.10:8080/RPC",
>>>>> "{\"jsonrpc\": \"2.0\", \"method\": \"ul.lookup\", \"params\":
>>>>> [\"location\",\"user\"], \"id\": 1}", "HTTP_REPLY");
>>>>>         xlog("L_ERR", "ASYNC1-$fU-$rU-$rm---- \n");
>>>>> }
>>>>>
>>>>> route[HTTP_REPLY] {
>>>>>         xlog("L_ERR", "HTTP_REPLY: ok $http_ok \n");
>>>>>         xlog("L_ERR", "HTTP_REPLY: status $http_rs\n");
>>>>>         xlog("L_ERR", "HTTP_REPLY: body   $http_rb\n");
>>>>>         xlog("L_ERR", "HTTP_REPLY: error  $http_err)\n");
>>>>> }
>>>>>
>>>>>
>>>>> In syslog I see HTTP_REPLY log strings with correct response, but do
>>>>> not see ASYNC1 string and script execution stops.
>>>>>
>>>>> What's wrong with this?
>>>>>
>>>>>
>>>>>
>>>>> #   kamailio -v
>>>>> version: kamailio 4.4.2 (x86_64/linux) 892ad6
>>>>> flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS,
>>>>> USE_RAW_SOCKS, DISABLE_NAGLE, USE_MCAST, DNS_IP_HACK, SHM_MEM, SHM_MMAP,
>>>>> PKG_MALLOC, Q_MALLOC, F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX,
>>>>> FAST_LOCK-ADAPTIVE_WAIT, USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR,
>>>>> USE_DST_BLACKLIST, HAVE_RESOLV_RES
>>>>> ADAPTIVE_WAIT_LOOPS=1024, MAX_RECV_BUFFER_SIZE 262144, MAX_LISTEN 16,
>>>>> MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
>>>>> poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
>>>>> id: 892ad6
>>>>> compiled on 12:58:38 Aug 28 2017 with gcc 4.8.5
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> --
>>>>>
>>>>> BR,
>>>>> Denys Pozniak
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> Kamailio (SER) - Users Mailing List
>>>>> sr-users at lists.kamailio.org
>>>>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>>>>
>>>>
>>>> _______________________________________________
>>>> Kamailio (SER) - Users Mailing List
>>>> sr-users at lists.kamailio.org
>>>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>>>
>>>>
>>>
>>>
>>> --
>>>
>>> BR,
>>> Denys Pozniak
>>>
>>>
>>>
>>
>>
>> --
>>
>> BR,
>> Denys Pozniak
>>
>>
>> _______________________________________________
>> Kamailio (SER) - Users Mailing List
>> sr-users at lists.kamailio.org
>> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>>
>
> _______________________________________________
> Kamailio (SER) - Users Mailing List
> sr-users at lists.kamailio.org
> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
>
>


-- 

BR,
Denys Pozniak
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20180927/82ba060a/attachment.html>


More information about the sr-users mailing list