Showing posts with label freeswitch. Show all posts
Showing posts with label freeswitch. Show all posts

Jul 12, 2013

running multiple freeswitch instances on one host

Lately I had a nasty stability problem, which I'm still investigating.
If you are curious, freeswitch locks up, and log shows repeating message:
....
[CRIT] switch_core_session.c:1634 Thread Failure!
[CRIT] switch_core_session.c:1593 LUKE: I'm hit, but not bad.
[CRIT] switch_core_session.c:1594 LUKE'S VOICE: Artoo, see what you can do with it. Hang on back there....
Green laserfire moves past the beeping little robot as his head turns. After a few beeps and a twist of his mechanical arm,
Artoo reduces the max sessions to XXX thus, saving the switch from certain doom.
....
While the message is amusing, and suggests that system is trying to recover, restart is required to bring it back to service. To reduce downtime and recovery time we decided to run two FS instances on single machine, since host capacity is not maxed out. There are multiple ways of doing this, but to minimize configuration changes I tried to set each instance to listen on specific ip of a multi-homed host.

Jun 17, 2012

FreeSWITCH on Amazon EC2

So far, work in progress, I'll update this post with additional details.

AWS security group

Before launching an instance, create new or extend existing security group, to allow sip/rtp ports.
Wide-open configuration is described here: http://wiki.freeswitch.org/wiki/Firewall

Instance

32 bit EBS Amazon Linux AMI from here: http://aws.amazon.com/amazon-linux-ami/
For testing, system can run on tiny instance, but you might want to run small instance to speed up compilation during system install.

Login as ec2-user.

Prerequisites

sudo yum update

sudo yum install git autoconf automake libtool ncurses-devel libjpeg-devel make gcc gcc-c++

sudo yum install expat-devel gnutls-devel libtiff-devel libX11-devel unixODBC-devel python-devel zlib-devel alsa-lib-devel libogg-devel libvorbis-devel perl-libs gdbm-devel uuid-devel

Build trunk version

git clone git://git.freeswitch.org/freeswitch.git
cd freeswitch
./bootstrap.sh

#here you might want to change modules.conf

./configure
make

Install the build

sudo make all install cd-sounds-install cd-moh-install

Configure service

sudo useradd freeswitch
sudo chown -R freeswitch:freeswitch /usr/local/freeswitch
sudo cp ./build/freeswitch.init.redhat /etc/init.d/freeswitch
sudo chmod +x /etc/init.d/freeswitch
echo "FS_FILE=/usr/local/freeswitch/bin/freeswitch" | sudo tee /etc/sysconfig/freeswitch
sudo mkdir /var/run/freeswitch/ 
sudo chown freeswitch:freeswitch /var/run/freeswitch/

sudo chkconfig --add freeswitch 
sudo chkconfig --levels 35 freeswitch on

Change default configuration

/usr/local/freeswitch/conf/vars.xml
Change default password 1234 to something less obvious.
EC2 instance ip address is different from public address, also it changes when machine restarts. Allocate elastic ip, configure dns name associated with this ip, and use it instead your_host.

diff -r conf/vanilla/vars.xml /usr/local/freeswitch/conf/vars.xml
15c15
<   <X-PRE-PROCESS cmd="set" data="default_password=1234"/>
---
>   <X-PRE-PROCESS cmd="set" data="default_password=your_password"/>
27c27
<   <X-PRE-PROCESS cmd="set" data="domain=$${local_ip_v4}"/>
---
>   <X-PRE-PROCESS cmd="set" data="domain=your_host"/>
168c168,169
<   <X-PRE-PROCESS cmd="set" data="external_rtp_ip=stun:stun.freeswitch.org"/>
---
>   <X-PRE-PROCESS cmd="set" data="external_rtp_ip=host:your_host"/>
181c182,183
<   <X-PRE-PROCESS cmd="set" data="external_sip_ip=stun:stun.freeswitch.org"/>
---
>   <X-PRE-PROCESS cmd="set" data="external_sip_ip=host:your_host"/>

auto-nat does not seem to work, define external ip explicitly for internal and external profiles:

/usr/local/freeswitch/conf/sip_profiles/external.xml
diff -r conf/vanilla/sip_profiles/external.xml /usr/local/freeswitch/conf/sip_profiles/external.xml
66,67c66,67
<     <param name="ext-rtp-ip" value="auto-nat"/>
<     <param name="ext-sip-ip" value="auto-nat"/>
---
>     <param name="ext-rtp-ip" value="$${external_rtp_ip}"/>
>     <param name="ext-sip-ip" value="$${external_sip_ip}"/>

/usr/local/freeswitch/conf/sip_profiles/internal.xml
diff -r conf/vanilla/sip_profiles/internal.xml /usr/local/freeswitch/conf/sip_profiles/internal.xml
268,269c268,269
<     <param name="ext-rtp-ip" value="auto-nat"/>
<     <param name="ext-sip-ip" value="auto-nat"/>
---
>     <param name="ext-rtp-ip" value="$${external_rtp_ip}"/>
>     <param name="ext-sip-ip" value="$${external_sip_ip}"/>

Launch the service

sudo service freeswitch start

At this point you should be able to register with zoiper or similar softphone, and make a call to 5000, to verify connectivity.
FreeSWITCH comes configured with some default extensions, this should work:

  • domain: your_host
  • user: 1000
  • password: your_password