Hello Daniel, hello List,
after reading the fresh released kemi documentation (Thanks for that!) on github i start to configure an kemi lua configuration. It seems to be that there is not an dispatcher export to kemi in my installation. Or i missconfigured something? How to use dispatcher with kemi?
1.) First try to solve this - use param "register" "modulename" to app_lua - doesnt work 2.) grep around in the auto kemi in/export messages in debug startup - nothing to see. 3.) grep around in the kamcmd api.list command for lua - no dispatcher
here the intressting parts of the configs and lua-script:
kamailio.cfg ... loadmodule "dispatcher.so" loadmodule "permissions.so" loadmodule "avpops.so" #!ifdef WITH_CFGLUA loadmodule "app_lua.so" modparam("app_lua", "reload", 1) modparam("app_lua", "register", "dispatcher") #!endif
#!ifdef WITH_CFGLUA modparam("app_lua", "load", "/etc/kamailio/lua/kamailio-kemi-lua.lua") cfgengine "lua" #!else import_file "request-route.cfg" #!endif ...
kamailio-kemi-lua.lua function ksr_request_route() ... -- dispatch destinations if KSR.permissions.allow_source_address(FLT_EDGE) then KSR.info("new $fU -> $rU in permissions"); direction = "inbound"; routing_target = FLT_FSNODE; ksr_route_dispatch(direction, routing_target); KSR.x.exit(); end
KSR.info("NOT-OKAY - $rU dropped"); -- End of Route() KSR.sl.sl_send_reply(407, "Proxy Authentication Required. See IP GUI"); return 1; ... end
--- dispatcher route function ksr_route_dispatch(direction, routing_target)
KSR.xlog.xinfo("new $fU -> $rU in routing_target ksr_route_dispatch"); KSR.info(routing_target); if (routing_target == nil) then KSR.xlog.xinfo("routing_target nil"); KSR.sl.sl_send_reply(604, "Does Not Exist Anywhere"); KSR.x.exit(); end
if KSR.dispatcher.ds_select_dst(routing_target, 4) then send_reply(404, "No destination"); KSR.x.exit(); end ksr_route_myheader(); ksr_route_relay(); KSR.x.exit(); end
/usr/sbin/kamailio[26763]: ERROR: app_lua [app_lua_api.c:713]: app_lua_run_ex(): error from Lua: /etc/kamailio/lua/kamailio-kemi-lua.lua:131: attempt to index field 'dispatcher' (a nil value)
kamailio -v version: kamailio 5.0.4 (x86_64/linux) flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, 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: unknown compiled on 20:20:24 Nov 16 2017 with gcc 4.8.5
rpm -aq | grep kam kamailio-mysql-5.0.4-26.el7.centos.x86_64 kamailio-5.0.4-26.el7.centos.x86_64 kamailio-lua-5.0.4-26.el7.centos.x86_64 kamailio-ims-5.0.4-26.el7.centos.x86_64
rpm -ql kamailio-5.0.4 | grep disp /usr/lib64/kamailio/modules/dispatcher.so /usr/share/doc/kamailio/modules/README.dispatcher /usr/share/kamailio/dbtext/kamailio/dispatcher
Hello List,
i dunno why this happen :) after i write an email to the list - but now i found it.
the app_lua/kemi function name is sr.dispatcher.select for ds_select_dst The source-code documentation guides me to this point after greping around in app_lua.
# dst_select( "GROUP", "HASH METHOD") if(!ds_select_dst($avp(routing_target), "4")) { send_reply("404", "No destination"); exit; }
In lua part it looks like this (the nil part maybe broken per default, lua dont like vars with nil)
--- dispatcher route function ksr_route_dispatch(direction, routing_target)
KSR.xlog.xinfo("new $fU -> $rU in routing_target ksr_route_dispatch"); KSR.info(routing_target); if (routing_target == nil) then KSR.xlog.xinfo("routing_target nil"); KSR.sl.sl_send_reply(604, "Does Not Exist Anywhere"); KSR.x.exit(); end
-- return code dispatcher.select NOT true - then 404 if (sr.dispatcher.select(routing_target, 4) ~= 1) then KSR.sl.sl_send_reply(404, "No destination"); KSR.x.exit(); end ksr_route_myheader(pathinfo); ksr_route_relay(); KSR.x.exit(); end
Hello,
On 22.11.17 12:42, Karsten Horsmann wrote:
Hello List,
i dunno why this happen :) after i write an email to the list - but now i found it.
the app_lua/kemi function name is sr.dispatcher.select for ds_select_dst
as wrote on my previous response to your initial email in this discussion, this is not via KEMI, the "sr" module in Lua is old style implementation, when for each function exported to Lua, new C code had to be written inside app_lua. But you can still use it, as in v5.0 many modules didn't export their functions to kemi.
Cheers, Daniel
The source-code documentation guides me to this point after greping around in app_lua.
# dst_select( "GROUP", "HASH METHOD") if(!ds_select_dst($avp(routing_target), "4")) { send_reply("404", "No destination"); exit; }
In lua part it looks like this (the nil part maybe broken per default, lua dont like vars with nil)
--- dispatcher route function ksr_route_dispatch(direction, routing_target)
KSR.xlog.xinfo("new $fU -> $rU in routing_target ksr_route_dispatch"); KSR.info(routing_target); if (routing_target == nil) then KSR.xlog.xinfo("routing_target nil"); KSR.sl.sl_send_reply(604, "Does Not Exist Anywhere"); KSR.x.exit(); end
-- return code dispatcher.select NOT true - then 404 if (sr.dispatcher.select(routing_target, 4) ~= 1) then KSR.sl.sl_send_reply(404, "No destination"); KSR.x.exit(); end ksr_route_myheader(pathinfo); ksr_route_relay(); KSR.x.exit(); end
-- Kind Regards *Karsten Horsmann*
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
Hello Daniel,
yes after playing around under kamailio-5.0.x, i understand that kemi exports are not complete.
For example the KSR.hdr.append_hf dont work in kamailio-5.0.x attempt to call field 'append_hf' (a nil value) KSR.hdr.append_hf("P-Hint: outbound\r\n"); But i found KSR.hdr.append("P-Hint: outbound\r\n"); (without _hf) - that did the same and works.
The hardest part with kemi seems to be "find the new kemi (function)name in your config-language" and also the module dependencies.
A few questions to kemi and kemi-docu:
* Are all config-language on the same level with the kemi-exports or are some "more ahead" - for example python or javascript?
* the behavior of "config-language exit - then exit kamailio" in lua makes me fear. With the old-school kamailio-cfg you cannot break kamailio itself. Pointing to nil values in app_lua / cfgengine lua or request nathelper module in kemi-lua without load nathelper - breaks your kamailio. huuuu. so many kamailio-cores today in my testlab. Are there changes in the future for this?
* Is it better to say "if you want kemi, then go to 5.1.x or master branch"?
Thanks!
2017-11-22 14:40 GMT+01:00 Daniel-Constantin Mierla miconda@gmail.com:
Hello,
On 22.11.17 12:42, Karsten Horsmann wrote:
Hello List,
i dunno why this happen :) after i write an email to the list - but now i found it.
the app_lua/kemi function name is sr.dispatcher.select for ds_select_dst
as wrote on my previous response to your initial email in this discussion, this is not via KEMI, the "sr" module in Lua is old style implementation, when for each function exported to Lua, new C code had to be written inside app_lua. But you can still use it, as in v5.0 many modules didn't export their functions to kemi.
Cheers, Daniel
The source-code documentation guides me to this point after greping around in app_lua.
# dst_select( "GROUP", "HASH METHOD") if(!ds_select_dst($avp(routing_target), "4")) { send_reply("404", "No destination"); exit; }
In lua part it looks like this (the nil part maybe broken per default, lua dont like vars with nil)
--- dispatcher route function ksr_route_dispatch(direction, routing_target)
KSR.xlog.xinfo("new $fU -> $rU in routing_target ksr_route_dispatch"); KSR.info(routing_target); if (routing_target == nil) then KSR.xlog.xinfo("routing_target nil"); KSR.sl.sl_send_reply(604, "Does Not Exist Anywhere"); KSR.x.exit(); end -- return code dispatcher.select NOT true - then 404 if (sr.dispatcher.select(routing_target, 4) ~= 1) then KSR.sl.sl_send_reply(404, "No destination"); KSR.x.exit(); end ksr_route_myheader(pathinfo); ksr_route_relay(); KSR.x.exit();
end
-- Kind Regards *Karsten Horsmann*
Kamailio (SER) - Users Mailing Listsr-users@lists.kamailio.orghttps://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users
-- Daniel-Constantin Mierlawww.twitter.com/miconda -- www.linkedin.com/in/miconda Kamailio Advanced Training - www.asipto.com Kamailio World Conference - May 14-16, 2018 - www.kamailioworld.com
Hello,
On 22.11.17 16:45, Karsten Horsmann wrote:
Hello Daniel,
yes after playing around under kamailio-5.0.x, i understand that kemi exports are not complete.
For example the KSR.hdr.append_hf dont work in kamailio-5.0.x attempt to call field 'append_hf' (a nil value) KSR.hdr.append_hf("P-Hint: outbound\r\n"); But i found KSR.hdr.append("P-Hint: outbound\r\n"); (without _hf) - that did the same and works.
append_hf() function is part of textops module. KSR.hdr subpackage is from core, somehow inspired from old app_lua sr.hdr subpackage. That was the reason to have different name, not to have a confusion on dependencies.
The hardest part with kemi seems to be "find the new kemi (function)name in your config-language" and also the module dependencies.
The functions available in KSR module and submodules are listed by:
kamctl rpc app_lua.api_list
A few questions to kemi and kemi-docu:
- Are all config-language on the same level with the kemi-exports or
are some "more ahead" - for example python or javascript?
In terms of functions, they should be pretty much in pair, in the way that any kemi function exported by core or a module is available immediately in all kemi languages. The only difference can be in the kemi functions implemented by the kemi-interpreter modules, respectively KSR.x subpackage.
KSR.pv is also implemented by each kemi-interpreter module, but that is because of KSR.pv.get() which needs special code for each interpreter, otherwise the functions in KSR.pv must be the same in all kemi languages, with the same behaviour in the script.
KSR.x is supposed to collect per kemi-interpreter specific functions or have code that is specific per interpeter. For example KSR.x.exit() has an implementation that reuses various tricks of the interpreter to stop execution of the kemi script.
- the behavior of "config-language exit - then exit kamailio" in lua
makes me fear.
Indeed, the native-lua 'exit' is stopping the lua interpreter completely, which in this case is kamailio, so it stops kamailio.
You have to use KSR.x.exit() instead.
With the old-school kamailio-cfg you cannot break kamailio itself.
Again, here is about the functions of the interpreter. I think that also in Python there is an system exit function that stops compeltely the interpreter (kamailio in this case).
So, the importat thing here is that the scripting language interpreter is kamailio itself, so the native functions for that scripting language behave as being run by the standalone interpreter.
Pointing to nil values in app_lua / cfgengine lua or request nathelper module in kemi-lua without load nathelper - breaks your kamailio. huuuu. so many kamailio-cores today in my testlab. Are there changes in the future for this?
I do not really get the above? If you do not load natherlper module, kamailio crashes of used with kemi lua engine? If yes, can you provide the backtrace with gdb from the core file? It needs to be fixed.
- Is it better to say "if you want kemi, then go to 5.1.x or master
branch"?
Not necessarily. Kemi framework code from core is more or less the same in 5.0 and 5.1, but the 5.1 has lot more kamailio functions exported to kemi. Based on your needs, using 5.0 with kemi can be sufficient.
Cheers, Daniel
Thanks!
2017-11-22 14:40 GMT+01:00 Daniel-Constantin Mierla <miconda@gmail.com mailto:miconda@gmail.com>:
Hello, On 22.11.17 12:42, Karsten Horsmann wrote:
Hello List, i dunno why this happen :) after i write an email to the list - but now i found it. the app_lua/kemi function name is sr.dispatcher.select for ds_select_dst
as wrote on my previous response to your initial email in this discussion, this is not via KEMI, the "sr" module in Lua is old style implementation, when for each function exported to Lua, new C code had to be written inside app_lua. But you can still use it, as in v5.0 many modules didn't export their functions to kemi. Cheers, Daniel
The source-code documentation guides me to this point after greping around in app_lua. # dst_select( "GROUP", "HASH METHOD") if(!ds_select_dst($avp(routing_target), "4")) { send_reply("404", "No destination"); exit; } In lua part it looks like this (the nil part maybe broken per default, lua dont like vars with nil) --- dispatcher route function ksr_route_dispatch(direction, routing_target) KSR.xlog.xinfo("new $fU -> $rU in routing_target ksr_route_dispatch"); KSR.info(routing_target); if (routing_target == nil) then KSR.xlog.xinfo("routing_target nil"); KSR.sl.sl_send_reply(604, "Does Not Exist Anywhere"); KSR.x.exit(); end -- return code dispatcher.select NOT true - then 404 if (sr.dispatcher.select(routing_target, 4) ~= 1) then KSR.sl.sl_send_reply(404, "No destination"); KSR.x.exit(); end ksr_route_myheader(pathinfo); ksr_route_relay(); KSR.x.exit(); end -- Kind Regards *Karsten Horsmann* _______________________________________________ Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org <mailto:sr-users@lists.kamailio.org> https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users <https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users>
-- Daniel-Constantin Mierla www.twitter.com/miconda <http://www.twitter.com/miconda> -- www.linkedin.com/in/miconda <http://www.linkedin.com/in/miconda> Kamailio Advanced Training - www.asipto.com <http://www.asipto.com> Kamailio World Conference - May 14-16, 2018 - www.kamailioworld.com <http://www.kamailioworld.com>
-- Kind Regards *Karsten Horsmann*
Hello,
version 5.0 doesn't have a lot of the functions from kamailio modules exported to kemi (KSR module). Not even v5.1 will have all of them, but I expect to be over 80% in v5.1.
There is a generic kemi function that can be used to execute any (most of) functions from modules KSR.x.modf(...):
- http://kamailio.org/docs/tutorials/devel/kamailio-kemi-framework/kemimods/#k...
If the kamctl rpc app_lua.api_list doesn't how a function you are looking for, then it is not yet available via kemi (in KSR module).
Doing the old way with "register" modparam can be a solution only for app_lua, if the respective module was added in the past to app_lua Lua exports.
Cheers, Daniel
On 22.11.17 11:24, Karsten Horsmann wrote:
Hello Daniel, hello List,
after reading the fresh released kemi documentation (Thanks for that!) on github i start to configure an kemi lua configuration. It seems to be that there is not an dispatcher export to kemi in my installation. Or i missconfigured something? How to use dispatcher with kemi?
1.) First try to solve this - use param "register" "modulename" to app_lua - doesnt work 2.) grep around in the auto kemi in/export messages in debug startup - nothing to see. 3.) grep around in the kamcmd api.list command for lua - no dispatcher
here the intressting parts of the configs and lua-script:
kamailio.cfg ... loadmodule "dispatcher.so" loadmodule "permissions.so" loadmodule "avpops.so" #!ifdef WITH_CFGLUA loadmodule "app_lua.so" modparam("app_lua", "reload", 1) modparam("app_lua", "register", "dispatcher") #!endif
#!ifdef WITH_CFGLUA modparam("app_lua", "load", "/etc/kamailio/lua/kamailio-kemi-lua.lua") cfgengine "lua" #!else import_file "request-route.cfg" #!endif ...
kamailio-kemi-lua.lua function ksr_request_route() ... -- dispatch destinations if KSR.permissions.allow_source_address(FLT_EDGE) then KSR.info("new $fU -> $rU in permissions"); direction = "inbound"; routing_target = FLT_FSNODE; ksr_route_dispatch(direction, routing_target); KSR.x.exit(); end
KSR.info("NOT-OKAY - $rU dropped"); -- End of Route() KSR.sl.sl_send_reply(407, "Proxy Authentication Required. See IP GUI"); return 1; ... end
--- dispatcher route function ksr_route_dispatch(direction, routing_target)
KSR.xlog.xinfo("new $fU -> $rU in routing_target ksr_route_dispatch"); KSR.info(routing_target); if (routing_target == nil) then KSR.xlog.xinfo("routing_target nil"); KSR.sl.sl_send_reply(604, "Does Not Exist Anywhere"); KSR.x.exit(); end
if KSR.dispatcher.ds_select_dst(routing_target, 4) then send_reply(404, "No destination"); KSR.x.exit(); end ksr_route_myheader(); ksr_route_relay(); KSR.x.exit(); end
/usr/sbin/kamailio[26763]: ERROR: app_lua [app_lua_api.c:713]: app_lua_run_ex(): error from Lua: /etc/kamailio/lua/kamailio-kemi-lua.lua:131: attempt to index field 'dispatcher' (a nil value)
kamailio -v version: kamailio 5.0.4 (x86_64/linux) flags: STATS: Off, USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, 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: unknown compiled on 20:20:24 Nov 16 2017 with gcc 4.8.5
rpm -aq | grep kam kamailio-mysql-5.0.4-26.el7.centos.x86_64 kamailio-5.0.4-26.el7.centos.x86_64 kamailio-lua-5.0.4-26.el7.centos.x86_64 kamailio-ims-5.0.4-26.el7.centos.x86_64
rpm -ql kamailio-5.0.4 | grep disp /usr/lib64/kamailio/modules/dispatcher.so /usr/share/doc/kamailio/modules/README.dispatcher /usr/share/kamailio/dbtext/kamailio/dispatcher
-- Kind Regards *Karsten Horsmann*
Kamailio (SER) - Users Mailing List sr-users@lists.kamailio.org https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-users