What is the simplest way to return values from external application into Kamailio config and assign it to a variable?
I'm looking for the most light weight mechanism to do it and to offload some logic to external app. Something like this would be ideal:
$var(myVar), $var(err) = lua_run("lua_func1", "$rU");
OR
$var(encString) = exec_cmd("echo 'abc $rU' | base64");
There is this method: http_client_query("http://...", "", "", "$var(result)"); but there is an overhead of networking and HTTP protocol.
Please advise.
Thanks, Dmytro
Hello,
if you are looking for a performance and light-solution, do not call an external script. 😉
Use the HTTP query methods, the overhead is much lower.
Cheers,
Henning
Hello,
On 08.02.23 23:30, Henning Westerholt wrote:
Hello,
if you are looking for a performance and light-solution, do not call an external script. 😉
Use the HTTP query methods, the overhead is much lower.
personally I would expect that exec (spawn + piping) to have less transmission overhead than http query even on connection reuse (building http message + network communication + parsing headers), but actually the reason I wrote is to point that if someone is concerned of the overhead and not sure what option to use, it can measure the performance with benchmark module.
Also, to be clearer, execution of a lua/python/... script via app_lua/app_python/... is not external script execution, the interpreter is embedded, so it is internal execution. This is definitely faster and preferred option compared to exec or http query.
Cheers, Daniel
Cheers,
Henning
-- Henning Westerholt – https://skalatan.de/blog/ Kamailio services – https://gilawa.com
-----Original Message----- From: Dmytro M mlistsdm@gmail.com Sent: Wednesday, February 8, 2023 7:16 PM To: Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org Subject: [SR-Users] Return value from lua/python/js/bash/etc... function
What is the simplest way to return values from external application into Kamailio config and assign it to a variable?
I'm looking for the most light weight mechanism to do it and to offload some logic to external app. Something like this would be ideal:
$var(myVar), $var(err) = lua_run("lua_func1", "$rU");
OR
$var(encString) = exec_cmd("echo 'abc $rU' | base64");
There is this method: http_client_query("http://...", "", "", "$var(result)"); but there is an overhead of networking and HTTP protocol.
Please advise.
Thanks, Dmytro __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
From embedded lua/python/etc., leverage $var(...) to pass the values, it can be done both ways, there are functions to get/set via KSR.pv or KSR.pvx:
- https://www.kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/core/#... Â - https://www.kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/module...
For exec, there is exec_avp() that could help.
Cheers, Daniel
On 08.02.23 19:16, Dmytro M wrote:
What is the simplest way to return values from external application into Kamailio config and assign it to a variable?
I'm looking for the most light weight mechanism to do it and to offload some logic to external app. Something like this would be ideal:
$var(myVar), $var(err) = lua_run("lua_func1", "$rU");
OR
$var(encString) = exec_cmd("echo 'abc $rU' | base64");
There is this method: http_client_query("http://...", "", "", "$var(result)"); but there is an overhead of networking and HTTP protocol.
Please advise.
Thanks, Dmytro __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe:
Thank you, Daniel! That's exactly what I was looking for.
In config I was able to use:
jsdt_run("myFunc","$rU", "$fU");
and return values from JS via:
function myFunc(ru, fu) { Â Â // ... Â KSR.pv.sets("$var(newFU)", "abc"); }
Regards, Dmytro
On 2023-02-09 03:21, Daniel-Constantin Mierla wrote:
From embedded lua/python/etc., leverage $var(...) to pass the values, it
can be done both ways, there are functions to get/set via KSR.pv or KSR.pvx:
- https://www.kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/core/#... Â - https://www.kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/module...
For exec, there is exec_avp() that could help.
Cheers, Daniel
On 08.02.23 19:16, Dmytro M wrote:
What is the simplest way to return values from external application into Kamailio config and assign it to a variable?
I'm looking for the most light weight mechanism to do it and to offload some logic to external app. Something like this would be ideal:
$var(myVar), $var(err) = lua_run("lua_func1", "$rU");
OR
$var(encString) = exec_cmd("echo 'abc $rU' | base64");
There is this method: http_client_query("http://...", "", "", "$var(result)"); but there is an overhead of networking and HTTP protocol.
Please advise.
Thanks, Dmytro __________________________________________________________ Kamailio - Users Mailing List - Non Commercial Discussions To unsubscribe send an email to sr-users-leave@lists.kamailio.org Important: keep the mailing list in the recipients, do not reply only to the sender! Edit mailing list options or unsubscribe: