[SR-Users] Kamailio sending HTTP request to another app
Olle E. Johansson
oej at edvina.net
Mon Nov 18 18:16:41 CET 2013
On 18 Nov 2013, at 15:45, Alex Balashov <abalashov at evaristesys.com> wrote:
> Hi Victor,
> Pretty much all HTTP calls, no matter how you architect them, block Kamailio SIP worker threads. There is a low practical limit to the number of of SIP worker threads you can have, so this can lead to SIP messages being dropped and sluggish response time very quickly.
The json-rpc module has what I believe is an asynch http call, returning in another route block.
I've mailed earlier about all our HTTP clients. There's a mess that needs someone to clean out.
> The exec_avp() function has this liability, as does the http_query() function in the 'utils' module, although the http_query() function does have a timeout parameter that works, so if a short timeout satisfies you, this is a superior alternative to exec_avp().
> However, to architect this in a truly asynchronous way, you're either going to have to query the thing you want via SIP (i.e. to a SIP redirect server) itself, or use some of the newer asynchronous/deferred processing features that are already in place, or being pushed into the 4.1 branch nowadays. Both options certainly incur greater complexity than using http_query(), so if the fact that it has a working timeout setting satisfies you, just use that.
> -- Alex
>  http://kamailio.org/docs/modules/4.0.x/modules/utils.html#idm1336
>  http://kamailio.org/docs/modules/4.0.x/modules/utils.html#idp2631720
>  http://kamailio.org/docs/modules/devel/modules/async.html
> On 11/18/2013 09:39 AM, Victor Torre Antunez wrote:
>> Hi all,
>> I´m using EXEC Module to execute a HTTP request via curl, to comunicate
>> with another app like this:
>> exec_avp("curl --connect-timeout 1 --max-time 2
>> http://IP_ADDR:PORT/PATH/'$fU'/'$tU'/'$hdr(Call-ID)'", "$avp(s:output)");
>> Sometimes Kamailio blocks when HTTP server does not response in time,
>> despite the max-time parameter.
>> I found this know issue on EXEC module docs:
>> "There is currently no guarantee that scripts ever return and stop
>> blocking SIP server. (There is kill.c but it is not used along with the
>> current mechanisms based on popen. Besides that kill.c is ugly)."
>> Does anyone know a better way to communicate Kamailio with a HTTP server
>> without blocks? I will try a python script to send the HTTP request and
>> call it with APP_PYTHON module. Has anyone had blocks with APP_PYTHON
>> Thanks in advance.
>> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
>> sr-users at lists.sip-router.org
> Alex Balashov - Principal
> Evariste Systems LLC
> 235 E Ponce de Leon Ave
> Suite 106
> Decatur, GA 30030
> United States
> Tel: +1-678-954-0670
> Web: http://www.evaristesys.com/, http://www.alexbalashov.com/
> SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list
> sr-users at lists.sip-router.org
More information about the sr-users