mysqlluaodbcvoipfreeswitch

How to connect to freeswitch remote database?


I have been trying to figure out if there is any way to connect to remote Database with FreeSwitch API.

FreeSwitch Lua API accepts only: Database name, username & password.

So it establishes the connection to localhost only.

local dbh = freeswitch.Dbh("odbc://my_db:uname:passwd") -- connect to ODBC database '

There is no option to provide host name if in case I want to make use of remote database server.

Is there any way ?

API Ref: https://freeswitch.org/confluence/display/FREESWITCH/Lua+with+Database


Solution

  • You can achieve this using connect database using an ODBC DSN.

    DB connect line in freeswitch

        freeswitch.Dbh("odbc://ODBC_DSN:DB_USERNAME:DB_PASSWD");
    

    ODBC configuration file(in my system it's on /etc/odbc.ini this path)

    [ODBC_DSN]
    Driver = /usr/lib/x86_64-linux-gnu/odbc/libmyodbc8a.so
    SERVER = #DB_HOST#
    PORT = #DB_PORT#
    DATABASE = #DB_NAME#
    USERNAME = #DB_USER_NAME#
    PASSWORD = #DB_PASSWORD#
    OPTION = 67108864
    Socket = /var/run/mysqld/mysqld.sock
    

    Reference link: https://freeswitch.org/confluence/pages/viewpage.action?pageId=6586653

    Hope this helps you.