Asterisk and openser realtime integration

I think this may be of use to some others who are using openser and asterisk together. Here are the views (you must use MySQL 5.0, or some other database with views) I created to allow asterisk realtime to pull from my openser subscriber list. A little rough, but they function well. You will have to create the asterisk database first, it’s not included in the script. Please post any corrections, or mail them to mwilliams@etc1.net.

USE openser;
ALTER TABLE subscriber
ADD vmail_password varchar(40) NULL,
ADD vmail BOOL DEFAULT TRUE;

USE asterisk;
CREATE VIEW voicemail AS
SELECT phplib_id as uniqueid,
username as customer_id,
‘default’ as context,
username as mailbox,
vmail_password as password,
CONCAT(first_name,’ ',last_name) as fullname,
email_address as email,
NULL as pager,
datetime_created as stamp
FROM openser.subscriber WHERE vmail = TRUE;

CREATE VIEW sip AS
SELECT username as name,
username,
‘friend’ as type,
NULL as secret,
‘dynamic’ as host,
CONCAT(rpid, ’ ‘,’<’,username,’>’) as callerid,
‘default’ as context,
username as mailbox,
‘no’ as nat,
‘no’ as qualify,
NULL as fromuser,
NULL as authuser,
NULL as fromdomain,
NULL as insecure,
‘no’ as canreinvite,
NULL as disallow,
NULL as allow,
NULL as restrictcid,
NULL as ipaddr,
NULL as port,
NULL as regseconds
FROM openser.subscriber;

You know, I just discovered today that SER/OpenSER only support DNS SRV lookups on the t_relay() function, and completely cache all host names supplied to functions in openser.cfg. How can you possibly use OpenSER/SER with Asterisk? It supports virtually no failover via DNS at all. How did you get around this?

We’re just using Asterisk as our voicemail server, and routing our calls to it with failure routes. I hadn’t heard about this limitation, but I’m not sure it affects us very much, since our clients will still have full DNS SRV support.

Also, I already found one bug in my setup. There seems to be an internal asterisk limitation to the length of the uniqueid field in the asterisk tables. Apparently 19 chars is the max. Unfortunately, it cuts it off during the update sql so that it is impossible to change voicemail passwords from a phone. I’m working on a fix. Any idea if I should try to fix (if it’s even a bug) asterisk, or try to work around the limitation first?

—Mike

Fixed, I think. It changes passwords at least… Let’s just hope it doesn’t seg fault or anything.

In asterisk source in apps/app_voicemail.c, change the size of uniqueid in the struct ast_vm_user to something larger than 20. I set mine to 128 to be safe.

—Mike

Another fix: The last line should be
FROM openser.subscriber;

otherwise, only people with voicemail can leave voicemails to the voicemail users.