Error! Unable to retrieve database handle. CDR failed

Hi,

I’m facing an issue with asterisk cdr table. Data is inserting successfully after call hangup. But the issue, I’m getting this below error.

[Jun 13 11:04:02] ERROR[18294]: cdr_odbc.c:175 odbc_log: Unable to retrieve database handle. CDR failed.

Below settings I’ve made in my config files. What’s wrong is going here? Can anyone have any idea?

/etc/asterisk/cdr_mysql.conf

[global]
hostname=localhost
dbname=asterisk
table=cdr
password=xxxx
user=xxxx

/etc/odbc.ini

[MySQL-asterisk]
Description = MySQL ODBC Driver Testing
Driver = MySQL
Socket = /var/run/mysqld/mysqld.sock
Server = localhost
User = xxxx
Password = xxxx
Database = asterisk

/etc/asterisk/cdr_odbc.conf

[global]
dsn=MySQL-asterisk
username=xxxx
password=xxxx
loguniqueid=yes
dispositionstring=yes

Nothing I’ve change in res_odbc.conf

/etc/asterisk/cdr_adaptive_odbc.conf

[adaptive_connection]
connection=asterisk
table=cdr

Note that my server config:
Asterisk 13.16.0
CentOS Linux release 7.3.1611 (Core)

Thanks in advance.

@jcolp can you have a look please if you are available. Sorry for tagging you.

When you posted this it was 3AM my time so tagging me wasn’t really needed. In fact I generally already respond to any posts which I have knowledge on.

If you haven’t changed anything in res_odbc.conf then your configuration is incomplete, as it is explicitly disabled in that file by default.

2 Likes

Thanks for the response. I’m really apologies for tagging you.
I’m checking and updating the res_odbc.conf file.

Hi,

Maybe this tutorial can help You http://www.minestron.it/node/352.

2 Likes

Thank you @jeanne. The problem has been resolved from your given link. :slight_smile:

Hi,
I followed The link that @jeanne posted, but with no luck!
Some times the call get stored in CDR table, but some other times I get the error : Unable to retrieve database handle. CDR failed. !!
Any help ?

What I learnt on how to resolve this error:
The DSN name in /etc/asterisk/cdr_odbc.conf must point to the section name in /etc/asterisk/res_odbc.conf.
The DSN name in /etc/asterisk/res_odbc.conf must point to the section name in /etc/odbc.ini
The Driver name in /etc/odbc.ini must point to the section name in /etc/odbcinst.ini

I hope this helps someone.

2 Likes