Wednesday, July 11, 2012

FreeSWITCH with SIP Users in MySQL [Mod XML_CURL]

FreeSWITCH is one of the biggest attraction for me since my introduction to VoIP. Since I like it too much and work with it most of the time but couldn't post anything good related to Freeswitch so far. Luckily I got a link from one of my friend's blog Touchkanalogy about Freeswitch module mod_xml_curl sort-of saying "FreeSWITCH SIP Realtime". Like Asterisk's SIP real-time where SIP users are inserted into database and asterisk authenticates incoming SIP user REGISTRATIONs from database settings.

FreeSWITCH don't exactly work like asterisk. FreeSWITCH needs XML configurations for users' settings. Following my friend's blog and the source document for the freeswitch XML_CURL  module. I was able to successfully insert users in Database and incoming SIP user's authentication requests were processed according to the data in DB.

Monday, July 9, 2012

Asterisk behind Kamailio & Voicemail MWI

Once again my workaholic nature didn't let me rest this Saturday and Sunday as I kept thinking about how can the MWI indications work with Asterisk as voicemail server behind a Kamailio server. Kamailio is the REGISTRAR of SIP users.

Since SIP users register on Kamailio, so Asterisk won't trigger a NOTIFY on it's voice-message recording.

There are many methods discussed on voip-info.org page. Among the other which weren't working or required patching I worked on manual SUBSCRIBE-NOTIFY triggering method by "Andreas Granig" which is openly discussed and shared on this mailing-list post in 2004. I haven't modified anything except the IP addresses for my servers.

Sunday, July 8, 2012

OpenSIPS working with Redis

I recently was trying some experiment to make opensips work with redis. This was pretty easy task but since Redis support in opensips is very new and not much of help is available and to be honest it doesn't require huge documentation to follow to make this work.

As I started on it, I got few minor problems which, I think, are worth writing here so that some other day when I forget these things I could read from here and refresh my memory.

We already know what is OpenSIPS, now what is Redis !?

Redis is a Key-Value pair storage tool running in memory - making it super fast, accessible over the network. Redis can be configured in cluster mode to save your data in case one node dies. To know more start from here. ;)

Thursday, July 5, 2012

OpenSIPS/Kamailio High Availability Clustering - 1

Using Heartbeat

I've been implementing SIP proxies (Either Kamailio or OpenSIPS) for some time now. These SIP proxies were mainly used to Load-balance the Media-Servers (Asterisks, FreeSWITCH mainly) and detect if any of the Media-Server is down and send its calls to some other available media-server. Thus we don;t need to worry about any of the Asterisk or FreeSWITCH crashes anymore.

But now the Single Point of Failure is the SIP proxy. If our SIP proxy application crashes or the server drops dead then we're nowhere !

In this post we will create a High-Available cluster of SIP proxy. There will be minimum of two SIP proxy servers (Physically unique) in one cluster.

One of the node will be defined as the primary node and our set of applications will run on the primary server. If the application set fails on primary node then our HearBeat will first try to restart it. If the restarting retries fails then it migrates the group of applications to the secondary node or any other node in the cluster.

HA Resources

The Set/Group of services which run on the any node in cluster are as follows (Priority in the order written)

1- Floating/Virtual IP
This IP is basically the only Public IP assigned on the cluster node. SIP proxy Listens to this address.

2- Linux Default Route

This will use Virtual IP configurations and use it as only way In&Out of Server to Internet.

3- SIP proxy

kamailio or OpenSIPSThis is the primary application which will be monitored for any crashes.

4- Add on Applications

Any other applications which are required in combination with SIP proxy and need to be started along with the SIP proxy i.e RTPproxy or Media-Proxy or any other application.


Setup Details
What this setup requires is atleast two physically unique serverswith atleast two NICs. eth0 IP of each server will have a unique Private IP, eth1 of both will be unused. The most important thing to mention here is that we don't set default-gateway on these machines. We can only access these machine from anyother third machine on Private IPs.

The only way these machines connect to internet is that they become primary node. When they become primary node the Public IP is assigned on eth1 and then default-gateway is set by the heartbeat application.
Once the default-gateway is set on primary node only then internet is accessible.


Setup Diagram

SIP proxy HA design

We have a separate independent Database for SIP proxy servers to save the User-Location Records. In case of primary server failure the secondary servers connects to the same DB and have all the registered users and active calls record in DB already. This is the key for this setup to work.

Read on to this blog's Second part on creating such a setup.