Bernhard, On line 5, you have more '(' than ')'. They need to balance. John On 12/10/14 18:27, Bernhard Wendel wrote:
Hi John,
what are you trying to tell me? Since I'm new to LUA you make me wonder whether there is a syntax error within my code. It should pop up somewhere, shouldn't it? Because I haven't found one and the code is actually working.
Or am I missing something?
Regards, Bernhard
Am 12.10.2014 17:21, schrieb John:
It looks like the parentheses don't match on line 5.
John
On 12/10/14 11:45, Bernhard Wendel wrote:
Hi,
I'm using the following Lua-Script to check whether a conference exists and only let a caller join if so. The script is called via the following dialplan /<action application="lua" data="/path/to/script.lua $1" />///, where $1 is the destination number.
1. -- Connect to a database 2. local dbh = freeswitch.Dbh("pgsql://hostaddr=127.0.0.1 dbname=database user=username password='password' application_name='my-lua-script'") 3. assert(dbh:connected()); 4. -- Execute SQL 5. dbh:query(string.format("SELECT COUNT(*) as \"MyCount\" FROM \"MyTable\" WHERE ColA = '%s'", argv[1]), function(row) 6. --freeswitch.consoleLog("INFO", "Results: " .. row.MyCount) 7. 8. dbh:release() 9. 10. if (row.MyCount== '1') then 11. freeswitch.consoleLog("INFO", "User is joining conference at " .. argv[1]) 12. 13. session:answer() 14. session:execute("conference", argv[1] .. "@wideband") 15. end 16. session:hangup() 17. end)
Line 8 instructs FS to return the postgres-Connection back to the pool - which is as expected. When a user now leaves the conference, FS throws this errors:
2014-10-12 10:32:30.065924 [DEBUG] switch_cpp.cpp:694 CoreSession::hangup 2014-10-12 10:32:30.065924 [CRIT] switch_pgsql.c:368 An error occurred trying to consume input for query (200): connection pointer is NULL 2014-10-12 10:32:30.065924 [CRIT] switch_pgsql.c:122 No DB Connection 2014-10-12 10:32:30.065924 [ERR] switch_core_sqldb.c:1177 ERR: [SELECT COUNT(*) as "MyCount" FROM "MyTable" WHERE ColA = 'conf-1234'][connection pointer is NULL] 2014-10-12 10:32:30.065924 [ERR] freeswitch_lua.cpp:446 DBH NOT Connected. 2014-10-12 10:32:30.065924 [DEBUG] switch_cpp.cpp:1075 sofia/internal/Alice@my.pbx.com destroy/unlink session from object
Now, I could live with that. BUT: The problem is, that sometimes, when a user leaves the conference, FS crashes. I've narrowed down the main cause to the above lua script. If I comment line 8 out, FS stops crashing. This will also stop FS from reusing Database-Connections.
Now my questions:
1. I don't use `dbh` after line 8. So where does the error come from? 2. How can I stop the error? 3. How can I rewrite the lua script to have both a) non-crashing FS and b) reusing of connection?
Regards, Bernhard
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org
_________________________________________________________________________ Professional FreeSWITCH Consulting Services: consulting@freeswitch.org http://www.freeswitchsolutions.com
Official FreeSWITCH Sites http://www.freeswitch.org http://confluence.freeswitch.org http://www.cluecon.com
FreeSWITCH-powered IP PBX: The CudaTel Communication Server http://www.cudatel.com
FreeSWITCH-users mailing list FreeSWITCH-users@lists.freeswitch.org http://lists.freeswitch.org/mailman/listinfo/freeswitch-users UNSUBSCRIBE:http://lists.freeswitch.org/mailman/options/freeswitch-users http://www.freeswitch.org