We have a Freeswitch installation as part of a FusionPBX GUI system. FusionPBX version 3.7.1, Freeswitch version 1.4.9. Database used by FusionPBX is Postgres.
The install compiles the Least Cost Routing module "mod_lcr" by default, and it is enabled in the module config file, module "/usr/local/freeswitch/mod/mod_lcr.so" is present.
However, I seem to be unable to use mod_lcr.
Issuing a command
reload mod_lcr
gives following errors:
2016-10-22 23:22:12.023181 [ERR] mod_lcr.c:1078 Unable to determine database RANDOM function
2016-10-22 23:22:12.023181 [DEBUG] mod_lcr.c:1110 param val is rate,quality,reliability
2016-10-22 23:22:12.023181 [DEBUG] mod_lcr.c:1113 arg #0/3 is rate
2016-10-22 23:22:12.023181 [DEBUG] mod_lcr.c:1113 arg #1/3 is quality
2016-10-22 23:22:12.023181 [DEBUG] mod_lcr.c:1113 arg #2/3 is reliability
2016-10-22 23:22:12.023181 [ERR] mod_lcr.c:2089 Unable to load lcr config file
2016-10-22 23:22:12.023181 [CRIT] switch_loadable_module.c:1447 Error Loading module /usr/local/freeswitch/mod/mod_lcr.so
**Module load routine returned an error**
I looked into the source code "mod_lcr.c" and I am not able to see what the error actually is. It clearly loads the config and executes part of the function "lcr_load_config" as can be seen by what is logged to the console above, but errors out at a point I cannot clearly identify.
It seems to have something to do with not having the database defined correctly for this module. In line 1056 of mod_lcr.c it should write the data source name to the log after having read the "setting" xml tag of the config, but it does not. The setting tag does exist - see below how the config looks like. But it does not set the "globals.odbc_dsn" variable.
The Freeswitch documentation for "mod_lcr" is very skimpy on this point and merely says to
"Edit the default configs for your profiles and database connection information /usr/local/freeswitch/conf/autoload_configs/lcr.conf.xml"
But what do I need to put into that config file?
By default in my install it contains:
<settings>
<param name="odbc-dsn" value="$${dsn_system}"/>
</settings>
I added the tables lcr, carriers, carrier_gateway to both the database "freeswitch" and "fusionpbx". No change, still the same error.
Any ideas what can be wrong here?
Figured it out myself.
The error was in fact missing database information. The error message "cannot read the config file" is misleading.
The point is that the FusionPBX install does not set the variable "dsn_system". One could set that variable, or explicitly state the connection string in the config file /usr/local/freeswitch/conf/autoload_configs/lcr.conf.xml.
So to improve on the Freeswitch manual page for mod_lcr, what you need to do in order to use "mod_lcr" is the following:
For Postgres databases this is rather simple. Here is the explicit setting in the lcr.conf.xml file: