Answer the question
In order to leave comments, you need to log in
How to connect to the mysql database on a remote host in Asterisk extensions.lua?
In general, the essence of the question is, I want to rewrite extensions.conf in extensions.lua. In general, everything is clear, and everything works until I tried to connect to the mysql database.
Below is the test dialplan:
extensions = {
deskphone = {
["_1XX"] = function (c,e)
app.NoOp("Extension "..e)
app.NoOp("Context "..c)
conn_mysql()
end;
["102"] = function(context, extension)
app.NoOp("Hello World")
end;
["101"] = function(c, e)
app.dial("PJSIP/"..e, 60)
end;
}
}
function conn_mysql()
package.cpath = package.cpath .. ";/usr/lib/x86_64-linux-gnu/lua/5.2/luasql/?.so"
env = assert (require"luasql.mysql".mysql())
con = assert (env:connect("asteriskdb","root","asterisk","asterisk-db"))
cur = assert (con:execute("SHOW TABLES"))
row = cur:fetch ()
while row do
print(row)
row = cur:fetch (row)
end
app.NoOp(" "..env)
env:close()
end
Answer the question
In order to leave comments, you need to log in
It doesn't tell me anything about anything. Of course, I’m not very good at lua, but there is enough memory there, and the script works fine if it is launched without being tied to the aster. That is, it displays a list of tables in the database, and when I run this function from the dialplan, this error appears.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question