jump to navigation

Storing Asterisk Real Time SIP Users in CSQL Main Memory Database October 15, 2009

Posted by Prabakaran Thirumalai in asterisk, csqlcache.
Tags: , ,

Asterisk uses sip.conf file to store the sip users and peers in the system. When developing application on asterisk, SIP users are addded and removed based dynamically. This requires restart of asterisk resulting in high down time. To avoid this, asterisk provides real time configuration where sip user information is stored in external database such as CSQL.

CSQL main memory database with its very small footprint and high throughput reduces the CPU load compared to general purpose database. This blog outlines the step by step procedure to set up CSQL for stroring asterisk real time SIP users.

For CSQL Installation andĀ Configuration, refer this blog.

Create table in CSQL for storing SIP users using either csql or isql tool. You may skip some of the fields except regserver, ipaddress, port, regseconds which are not used in your sip.conf file. The column names in CSQL database table correspond to the option names in sip.conf.

CREATE TABLE sip_buddies ( id int auto_increment, name char(80) NOT NULL default ”, host char(31) NOT NULL default ”, nat char(5) NOT NULL default ‘no’, type char(10) NOT NULL default ‘friend’, accountcode char(20), amaflags char(13), call_limit smallint, callgroup char(10) , callerid char(80) , cancallforward char(3) default ‘yes’, canreinvite char(3) default ‘yes’, context char(80) , defaultip char(15) , dtmfmode char(7) , fromuser char(80) , fromdomain char(80) , insecure char(4) , language char(2) , mailbox char(50) , md5secret char(80) , deny char(95) , permit char(95) , mask char(95) , musiconhold char(100) , pickupgroup char(10) , qualify char(3) , regexten char(80) , restrictcid char(3) , rtptimeout char(3) , rtpholdtimeout char(3) , secret char(80) , setvar char(100) , disallow char(100) default ‘all’, allow char(100) default ‘ulaw’, fullcontact char(80) default ”, ipaddr char(15) default ”, port smallint default ‘0’, regserver char(100) , regseconds int default ‘0’, lastms int default ‘0’, username char(80) default ”, defaultuser char(80) default ”, subscribecontext char(80));
CREATE INDEX sip_buddies_indx on sip_buddies(name)unique;
INSERT INTO sip_buddies (id, name, callerid, context, canreinvite, insecure, type,

host, secret, allow, nat) VALUES (‘1′,’500′,’500′,’mycontext’,’no’,’no’,’peer’,

‘dynamic’,’500′ ,’ulaw’,’no’);

Add below lines to extconfig.conf

sippeers => odbc,mycsql,sip_buddies
sipusers => odbc,mycsql,sip_buddies

Register with SIP user 500 and password 500. It will succeed. Verify the registration status in asterisk console.

IAX and H323 users can also be stored the same way in CSQL for reducing the processing time.

More Information




1. mostafa - June 26, 2013

if we have a configuration for extensions in file sip.conf, the system skip database configuration and use on in sip.conf, how can i force first priority for database?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: