[SR-Users] HTTP Requests for API routing - Question on which module to use with KSR

Emilio Panighetti emiliop at operalogic.com
Wed Dec 8 06:17:32 CET 2021


Looking into using Kamailio to route calls via an HTTP API.

Basic scenario is this:
INVITE comes in (no registration). And Kamailio sends an HTTP request to a server with data extracted from the INVITE.
Based on the response, call KSR.setdsturi() and other actions like normalizing phone numbers, etc. (Not sure if changing Contact: headers would be a better option). For now I want to be able to make a simple call routing as a proof of concept. Planning on using Lua as a KEMI interpreter.

Looking at different modules:

http_client
http_client_async
xhttp

Which module would be more appropriate?
http_client_async provides a simple async method and callback, so the SIP threads can continue processing requests while the API server is preparing the response. But the call has to be parked (How is this done?) and this is also an overhead.

http_client seems straightforward, but the SIP threads are tied up waiting for HTTP responses.
Also looking at the KEMI documentation, the KSR function calls for HTTP_CLIENT doesn’t seem to match the config function documentation.

For example, In KEMI manual: KSR.http_client.curl_connect_post() doesn’t have a corresponding in kamailio.cfg.

So which would be the preferred approach? Also examples would be appreciated.

Thanks in advance!


More information about the sr-users mailing list