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

4 comments:

Unknown said...

Hi, excuse me, in your experience how many concurrent users can have an Ec2 instance using Freeswitch?

Unknown said...

Sorry your message stuck in moderation, and I didn't get the email about it.
I didn't have production load, but tiny instance was able to process 50 concurrent simulated calls without degradation. I didn't try more.
Testing process wasn't ideal - I executed automated calls, and called in myself via soft-phone few times. In my call sound was clear. But your mileage might vary - average call time, idle in-session time between playback&recording, size&format of playback files, logging level, any of these parameters might change your number significantly both ways.

Unknown said...

Hello can you help me figure out why i get this error

make: *** No targets specified and no makefile found. Stop.

when i follow your steps... and i run "make" this is what i get :(

Unknown said...

Konstantin, I'd guess your previous step of ./configure returned errors.

You can try your luck on irc, to get some assistance in real-time:

http://webchat.freenode.net/?channels=freeswitch