<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16609" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>I am running CentOS 5 with Asterisk 1.4.14. I
am trying to setup storage of voicemail messages into MySQL. It is my
understanding that I can only do this via ODBC. I installed per <A
href="http://www.voip-info.org/wiki/view/CentOS+5+and+Asterisk+1.4.x+installation">http://www.voip-info.org/wiki/view/CentOS+5+and+Asterisk+1.4.x+installation</A>
unixODBC unixODBC-devel libtool-ltdl libtool-ltdl-devel and
mysql-connector-odbc. I reconfigured and built Asterisk, using menuconfig to
turn on ODBC voicemail storage. Here is the output of some config
files:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>[root@Aiur asterisk]# cat /etc/odbcinst.ini<BR>#
Example driver definitinions<BR>#<BR>#</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2># Included in the unixODBC
package<BR>#[PostgreSQL]<BR>#Description = ODBC for
PostgreSQL<BR>#Driver =
/usr/lib/libodbcpsql.so<BR>#Setup
= /usr/lib/libodbcpsqlS.so<BR>#FileUsage =
1</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV><FONT face=Arial size=2>
<DIV><BR># Driver from the MyODBC package<BR># Setup from the unixODBC
package<BR>[MySQL]<BR>Description = ODBC for
MySQL<BR>Driver =
/usr/lib64/libmyodbc3.so<BR>Setup
= /usr/lib64/libodbcmyS.so<BR>FileUsage =
1<BR>You have new mail in /var/spool/mail/root<BR>[root@Aiur asterisk]# cat
/etc/odbc.ini<BR>[astrealtime]<BR>Description = Asterisk
realtime FUNC_ODBC
access<BR>Driver =
MySQL<BR>Socket =
/var/lib/mysql/mysql.sock<BR>Server
=
localhost<BR>User
=
astrealtime<BR>Pass
= XXXX<BR>Database =
asterisk<BR>Option =
3<BR>[root@Aiur asterisk]# cat /etc/asterisk/res_odbc.conf<BR>;;; odbc
setup file</DIV>
<DIV> </DIV>
<DIV>; ENV is a global set of environmental variables that will get set.<BR>;
Note that all environmental variables can be seen by all connections,<BR>; so
you can't have different values for different
connections.<BR>[ENV]<BR>INFORMIXSERVER => my_special_database<BR>INFORMIXDIR
=> /opt/informix</DIV>
<DIV> </DIV>
<DIV>; All other sections are arbitrary names for database connections.</DIV>
<DIV> </DIV>
<DIV>[asterisk]<BR>enabled => no<BR>dsn => asterisk<BR>;username =>
myuser<BR>;password => mypass<BR>pre-connect => yes</DIV>
<DIV> </DIV>
<DIV><BR>[mysql]<BR>enabled => yes<BR>dsn => MySQL-asterisk<BR>username
=> astrealtime<BR>password => XXXX<BR>pre-connect => yes</DIV>
<DIV> </DIV>
<DIV>; Certain servers, such as MS SQL Server and Sybase use the TDS protocol,
which<BR>; limits the number of active queries per connection to 1. By
setting up pools<BR>; of connections, Asterisk can be made to work with these
servers.<BR>[sqlserver]<BR>enabled => no<BR>dsn => mickeysoft<BR>pooling
=> yes<BR>limit => 5<BR>username => oscar<BR>password =>
thegrouch<BR>pre-connect => yes</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV><BR>[root@Aiur asterisk]# cat
/etc/asterisk/voicemail.conf<BR>odbcstorage=mysql<BR>odbctable=voicemail_messages<BR></DIV>
<DIV>[root@Aiur asterisk]# asterisk -vvv | grep odbc<BR> == Parsing
'/etc/asterisk/res_odbc.conf': Found<BR>[Feb 22 18:21:46] NOTICE[21214]:
res_odbc.c:229 load_odbc_config: Adding ENV var:
INFORMIXSERVER=my_special_database<BR>[Feb 22 18:21:46] NOTICE[21214]:
res_odbc.c:229 load_odbc_config: Adding ENV var:
INFORMIXDIR=/opt/informix<BR>[Feb 22 18:21:46] NOTICE[21214]: res_odbc.c:508
odbc_obj_connect: Connecting mysql<BR>[Feb 22 18:21:46] WARNING[21214]:
res_odbc.c:519 odbc_obj_connect: res_odbc: Error SQLConnect=-1 errno=0
[unixODBC][Driver Manager]Data source name not found, and no default driver
specified<BR>[Feb 22 18:21:46] WARNING[21214]: res_odbc.c:444
ast_odbc_request_obj: Failed to connect to mysql<BR>[Feb 22 18:21:46]
NOTICE[21214]: res_odbc.c:302 load_odbc_config: Registered ODBC class 'mysql'
dsn->[MySQL-asterisk]<BR>[Feb 22 18:21:46] NOTICE[21214]: res_odbc.c:684
load_module: res_odbc loaded.<BR>res_odbc.so => (ODBC Resource)<BR>[Feb 22
18:21:46] NOTICE[21214]: config.c:1250 ast_config_engine_register: Registered
Config Engine odbc<BR>res_config_odbc loaded.<BR>res_config_odbc.so => (ODBC
Configuration)<BR> == Parsing '/etc/asterisk/func_odbc.conf':
Found<BR>func_odbc.so => (ODBC lookups)<BR> == Parsing
'/etc/asterisk/cdr_odbc.conf': Found<BR>cdr_odbc.so => (ODBC CDR
Backend)</DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV> </DIV>
<DIV>[root@Aiur asterisk]# mysql -u root -p<BR>Enter password:<BR>Welcome to the
MySQL monitor. Commands end with ; or \g.<BR>Your MySQL connection id is
22 to server version: 5.0.22</DIV>
<DIV> </DIV>
<DIV>Type 'help;' or '\h' for help. Type '\c' to clear the buffer.</DIV>
<DIV> </DIV>
<DIV>mysql> use asterisk;<BR>Reading table information for completion of
table and column names<BR>You can turn off this feature to get a quicker startup
with -A</DIV>
<DIV> </DIV>
<DIV>Database changed<BR>mysql> describe
voicemail_messages;<BR>+----------------+-------------+------+-----+---------+----------------+<BR>|
Field |
Type | Null | Key | Default |
Extra
|<BR>+----------------+-------------+------+-----+---------+----------------+<BR>|
id |
int(11) | NO | PRI | NULL
| auto_increment |<BR>| msgnum |
int(11) | NO | |
0
|
|<BR>| dir |
varchar(80) | YES | MUL | NULL
|
|<BR>| context | varchar(80) |
YES | | NULL
|
|<BR>| macrocontext | varchar(80) | YES
| | NULL
|
|<BR>| callerid | varchar(40) | YES
| | NULL
|
|<BR>| origtime | varchar(40) | YES
| | NULL
|
|<BR>| duration | varchar(20) | YES
| | NULL
|
|<BR>| mailboxuser | varchar(80) | YES
| | NULL
|
|<BR>| mailboxcontext | varchar(80) | YES | |
NULL
|
|<BR>| recording | longblob |
YES | | NULL
|
|<BR>+----------------+-------------+------+-----+---------+----------------+<BR>11
rows in set (0.00 sec)</DIV>
<DIV> </DIV>
<DIV>mysql> exit;<BR>Bye<BR></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Here is an example of the errors I'm getting
(ignore No route to destination, those phones just aren't on):</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2> -- Executing
Goto("SIP/2441-ac047f90", "rwest|815XXXXXXX|1")<BR> -- Goto
(rwest,815XXXXXXX,1)<BR> -- Executing
NoOp("SIP/2441-ac047f90", "CallerID is "WIRELESS CALLER"
<XXXXXXX>")<BR> -- Executing Dial("SIP/2441-ac047f90",
"SIP/rwest200&SIP/rwest201&SIP/rwest202&SIP/rwest203|15")<BR>[Feb 22
18:14:42] WARNING[21068]: app_voicemail.c:2233 inboxcount: Failed to obtain
database object for 'asterisk'!<BR> -- Called rwest200<BR>[Feb
22 18:14:42] WARNING[21149]: app_dial.c:1111 dial_exec_full: Unable to create
channel of type 'SIP' (cause 3 - No route to destination)<BR>[Feb 22 18:14:42]
WARNING[21149]: app_dial.c:1111 dial_exec_full: Unable to create channel of type
'SIP' (cause 3 - No route to destination)<BR>[Feb 22 18:14:42] WARNING[21149]:
app_dial.c:1111 dial_exec_full: Unable to create channel of type 'SIP' (cause 3
- No route to destination)<BR>[Feb 22 18:14:42] NOTICE[21068]: chan_sip.c:12414
handle_response_peerpoke: Peer 'rwest200' is now Reachable. (37ms /
2000ms)<BR> -- SIP/rwest200-19612180 is ringing<BR>[Feb 22
18:14:53] WARNING[21068]: app_voicemail.c:2233 inboxcount: Failed to obtain
database object for 'asterisk'!<BR> -- Nobody picked up in
15000 ms<BR>[Feb 22 18:14:57] NOTICE[21149]: cdr.c:434 ast_cdr_free: CDR on
channel 'SIP/rwest200-19612180' not posted<BR> -- Executing
BackGround("SIP/2441-ac047f90",
"/var/lib/asterisk/sounds/rwestgreeting")<BR> --
<SIP/2441-ac047f90> Playing '/var/lib/asterisk/sounds/rwestgreeting'
(language 'en')<BR>[Feb 22 18:15:04] WARNING[21068]: app_voicemail.c:2233
inboxcount: Failed to obtain database object for 'asterisk'!<BR> == CDR
updated on SIP/2441-ac047f90<BR> -- Executing
Voicemail("SIP/2441-ac047f90", "<A
href="mailto:200@rwest|u">200@rwest|u</A>")<BR>[Feb 22 18:15:09] WARNING[21149]:
app_voicemail.c:1122 retrieve_file: Failed to obtain database object for
'asterisk'!<BR>[Feb 22 18:15:09] WARNING[21149]: app_voicemail.c:1122
retrieve_file: Failed to obtain database object for 'asterisk'!<BR>[Feb 22
18:15:09] WARNING[21149]: app_voicemail.c:1122 retrieve_file: Failed to obtain
database object for 'asterisk'!<BR> --
<SIP/2441-ac047f90> Playing 'vm-theperson' (language
'en')<BR> -- <SIP/2441-ac047f90> Playing 'digits/2'
(language 'en')<BR> -- <SIP/2441-ac047f90> Playing
'digits/0' (language 'en')<BR> -- <SIP/2441-ac047f90>
Playing 'digits/0' (language 'en')<BR> --
<SIP/2441-ac047f90> Playing 'vm-isunavail' (language
'en')<BR> -- <SIP/2441-ac047f90> Playing 'vm-intro'
(language 'en')<BR>[Feb 22 18:15:15] WARNING[21068]: app_voicemail.c:2233
inboxcount: Failed to obtain database object for 'asterisk'!<BR>[Feb 22
18:15:20] WARNING[21149]: app_voicemail.c:1187 last_message_index: Failed to
obtain database object for 'asterisk'!<BR> --
<SIP/2441-ac047f90> Playing 'beep' (language 'en')<BR>
-- Recording the message<BR> -- x=0, open writing:
/var/spool/asterisk/voicemail/rwest/200/tmp/me15Bl format: wav,
0x19652c30<BR>[Feb 22 18:15:26] WARNING[21068]: app_voicemail.c:2233 inboxcount:
Failed to obtain database object for 'asterisk'!<BR> -- User
hung up<BR>[Feb 22 18:15:26] WARNING[21149]: app_voicemail.c:1233
message_exists: Failed to obtain database object for 'asterisk'!<BR>[Feb 22
18:15:26] WARNING[21149]: app_voicemail.c:1263 delete_file: Failed to obtain
database object for 'asterisk'!<BR>[Feb 22 18:15:26] WARNING[21149]:
app_voicemail.c:1400 store_file: Failed to obtain database object for
'asterisk'!<BR>[Feb 22 18:15:26] WARNING[21149]: app_voicemail.c:1122
retrieve_file: Failed to obtain database object for 'asterisk'!<BR>[Feb 22
18:15:26] WARNING[21149]: app_voicemail.c:2277 messagecount: Failed to obtain
database object for 'asterisk'!<BR>[Feb 22 18:15:26] WARNING[21149]:
app_voicemail.c:2277 messagecount: Failed to obtain database object for
'asterisk'!<BR> == Spawn extension (rwest, 300, 1) exited non-zero on
'SIP/2441-ac047f90'<BR></FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>----------<BR>Mike Hammett<BR>Intelligent Computing
Solutions<BR><A
href="http://www.ics-il.com">http://www.ics-il.com</A></FONT></DIV>
<DIV> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>