Asterisk wouldn't connect through ODBC

Hi everyone,

I’m using Asterisk 1.8 on OpenSuse 11.3 and I’m trying to use a MySQL database to configure Asterisk, but Asterisk doesn’t connect through odbc. MySql and ODBC do function, but Asterisk doesn’t have any res_odbc.so to load since I cann’t run odbc show in the CLI. I tried to copy res_odbc.so from my source folder to the asterisk module folder and it tells me:

[Apr 26 15:33:28] WARNING[25710]: loader.c:777 inspect_module: Module 'res_odbc.so' was not compiled with the same compile-time options as this version of Asterisk. [Apr 26 15:33:28] WARNING[25710]: loader.c:778 inspect_module: Module 'res_odbc.so' will not be initialized as it may cause instability. [Apr 26 15:33:28] WARNING[25710]: loader.c:861 load_resource: Module 'res_odbc.so' could not be loaded.
My configurations are as follows:
/etc/unixODBC/odbcinst.ini

[MySQL] Driver = /usr/lib/unixODBC/libmyodbc3.so Setup = /usr/lib/unixODBC/libodbcmyS.so FileUsage = 1
Testing the drive

# odbcinst -q -d [MySQL]
/etc/unixODBC/odbc.ini

[asterisk-connector]
Description           = MySQL connection to 'asterisk' database
Driver                = MySQL
Database              = asterisk
Server                = localhost
UserName              = myusername 
Password              = mypassword
Port                  = 3306
Socket                = /var/run/mysql/mysql.sock[/code]
Validating ODBC
[code] # echo "select 1" | isql -v asterisk-connector
[MYODBCUtilReadDataSource.c][243][ERROR] Unknown attribute (UserName).
+---------------------------------------+
| Connected!                            |
|                                       |
| sql-statement                         |
| help [tablename]                      |
| quit                                  |
|                                       |
+---------------------------------------+
SQL> +---------------------+
| 1                   |
+---------------------+
| 1                   |
+---------------------+
SQLRowCount returns 1
1 rows fetched
SQL> # 

Then I did ./configure, make menuselect and make install. I made sure the necessary modules (cdr_odbc, cdr_adaptive_odbc,func_odbc, func_realtime, pbx_realtime, res_config_odbc, and res_odbc) were selected.
etc/asterisk/res_odbc.conf

[asterisk]
enabled => yes
dsn => asterisk-connector
username => myusername
password => mypassword
pre-connect => yes
pooling => no
limit => 1

Then I started Asterisk, but odbc show could not be run.
When I configure something in extconfig.conf, I always receive the warning that the mysql engine is not available.
Does any one have an idea, I’ve been working on this for almost a week now.

Thanks in advance :confused:

Hi,

I myself am struggling with the ODBC connection, but :

My odbc.ini contains USER= … Yours contains UserName …

Considering it gives an error about the username you might have to change this to User= …

Hope that helps.

With kind regards
Marco

Hi Marco,

thanks for the reply. I used User and the isql error is gone, but my problem still remains even after reloading Asterisk.

Thanks

Did you compile everything from source on the destination machine ?

Hi Marco,

how do you mean it. I compiled from the source, the untared Asterisk directory.

Hi,

I am not an expert in asterisk, but as far as i can see the odbc module is giving a complaint that could be related to your compile.

That is strange, most people with this error with this error have installed it with a package manager.

There are several step for step tutorials available for a basic install, i would try following one step by step to make sure you dont forget a step. Look carefully at the feedback you are getting during the compile, it might give you some useful hints about what is going wrong. Also try to set the logging of asterisk to the highest debug level and a lot more information will be shown in the logs.

In short i compiled it like this:
In asterisk source directory:

[quote]./configure --with-odbc
make menuconfig (To select the options we need, or don’t need.)
make
make install [/quote]

I didnt have any problems loading the odbc module with these compile options.
I hope this helps.

Regards,
Marco

Hi Marco,

I solved it by uninstalling Asterisk 1.8 and installing Asterisk 10.3.

Thanks though.