From damm@sipgate.de Wed Jun 14 11:25:57 2017 From: Sebastian Damm To: sr-users@lists.kamailio.org Subject: [SR-Users] app_lua and sqlops returns error Date: Wed, 14 Jun 2017 11:25:34 +0200 Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="===============0825656793==" --===============0825656793== Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Hi, I'm developing some routing logic with Kamailio 5.0.1 and app_lua. I've integrated my lua script and now I'm trying to use sqlops within the script. I want to use the reconnect stuff of sqlops instead of implementing it by myself. This is what the Kamailio config looks like: [..] loadmodule "db_mysql.so" loadmodule "sqlops.so" loadmodule "app_lua.so" [..] modparam("sqlops", "sqlcon", "ca=3D>mysql://kamailio:foobar(a)127.0.0.1/kamai= lio") modparam("app_lua", "reload", 1) modparam("app_lua", "register", "sqlops") modparam("app_lua", "load", "/etc/kamailio/playground.lua") ####### Routing Logic ######## # Main SIP request routing logic request_route { route(everythinginlua); } onreply_route { route(everythinginlua); } route[everythinginlua] { if(!lua_run("handle_packet")) { xlog("L_ERR", "SCRIPT: failed to execute lua function!\n"); } drop; exit; } The lua script looks like this: -- Start of script function handle_packet() sr.log("L_INFO", "Got packet method "..sr.pv.get("$rm")) local status =3D sr.sqlops.sql_query("ca", "SELECT * FROM table", "fooresul= t") sr.err("sql query returned status "..status) end -- End of script Now when a packet comes in, I see the following in the log file: Jun 14 11:19:59 busch /usr/sbin/kamailio[13254]: ERROR: app_lua [app_lua_sr.c:104]: lua_sr_log(): Got packet method REGISTER Jun 14 11:19:59 busch /usr/sbin/kamailio[13254]: ERROR: app_lua [app_lua_api.c:713]: app_lua_run_ex(): error from Lua: /etc/kamailio/playground.lua:4: attempt to call field 'sql_query' (a nil value) Jun 14 11:19:59 busch /usr/sbin/kamailio[13254]: ERROR: app_lua [app_lua_api.c:726]: app_lua_run_ex(): error executing: handle_packet (err: 2) Jun 14 11:19:59 busch /usr/sbin/kamailio[13254]: ERROR: