[SR-Users] kemi with lua and dispatcher - attempt to index field 'dispatcher' (a nil value)

Karsten Horsmann khorsmann at gmail.com
Wed Nov 22 16:45:33 CET 2017


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 at 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 at 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
>
>


-- 
Kind Regards
*Karsten Horsmann*
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.kamailio.org/pipermail/sr-users/attachments/20171122/1cff66ef/attachment.html>


More information about the sr-users mailing list