Michigan Telephone and I have been discussing using FreeSWITCH as an on-box adjunct to Asterisk to enable cutting-edge features, such as Google Voice integration, without having to use development-level Asterisk code. Here’s how to set up a very minimal FreeSWITCH on the same server as Asterisk for this very purpose.
References, at the top of the post to suggest that you read these first:
- FreeSWITCH Wiki – Installation Guide
- FreeSWITCH Wiki – Google Voice
- AA-Asterisk Wiki on setting up a minimal FreeSWITCH installation
- Helpful folks on IRC #freeswitch
- Follow the installation guide to retrieve the development version of FreeSWITCH from the git repository. Warning! The Subversion repository is old, and so is the tarball, which claims to be a nightly snapshot. It is not. Only git will get you the current code.
- Edit modules.conf in the source directory and uncomment endpoints/mod_dingaling. Later, once you see the minimal installation we’re producing, you may want to comment out other unused modules to save some build time.
make install. My Asterisk box already had most of the required libraries; only libtiff-devel was missing (needed for the spandsp module). I was able to retrieve libraries and headers with yum (
yum install libtiff-develfor example). The make process will alert you of anything missing. Just install the requirements and then
makeagain, and it will pick up where it left off.
- FreeSWITCH will now be installed in /usr/local/freeswitch and is contained within this directory and subdirectories. I noticed that it builds its own copy of iksemel, which I already have installed elsewhere for Asterisk’s use, but the custom libs are in /usr/local/freeswitch/lib so there is no interference.
- Delete the contents of /usr/local/freeswitch/conf. You can get them back later if you want by doing
make samplesfrom your FreeSWITCH source directory, but for this minimal installation, we can put all of the configuration in a single file and be sure nothing else is loading.
- I spent some time trying to optimize the FreeSWITCH config so that it contains just enough to act as a gateway between Asterisk (using SIP) and Google Voice. My freeswitch.xml config, appended to this post, should work for anyone following these steps. Copy it to the /usr/local/freeswitch/conf directory, editing the lines related to GMail login.
- If you’re set up for NAT, you may not (probably don’t) have the loopback network configured in your sip.conf as a local (non-NAT) network. Add
localnet = 127.0.0.0/255.255.255.0to [general] in sip.conf or the sip_nat.file if you’re using FreePBX. Otherwise, Asterisk will try to use NAT-traversal methods for the Asterisk-FreeSWITCH on-box trunk.
- Set up a new SIP trunk. In FreePBX, name the peer “freeswitch” and use these trunk details:
(FreePBX now sets up contexts appropriately within from-trunk, so the context line can be omitted here unless you wish to specify one.) The non-FreePBX method would be to create a
[freeswitch]block in sip.conf with the aforementioned details and an appropriate
context=line. That’s it. No registration, no usernames, nothing–we are authenticating by IP address and port only.
- Set up appropriate inbound and outbound routes in FreePBX or in your extensions.conf dialplan. This is outside the scope of this how-to.
FreeSWITCH and/or the GTalk/Jingle protocol use more RTP ports than what I had previously configured in my router-firewall for Asterisk. So I updated my firewall to include UDP ports 10000-65000.
Google Voice and GMail
- Log into the GMail account with an associated Google Voice number, bring up the chat window and enable voice calling. Call a number and see that it works through your browser.
- Log into Google Voice and instruct it to route calls to Google Chat. According to the FreeSWITCH wiki, the FreeSWITCH integration only works when call screening is turned on. (Why?) So turn it on. Call your Google Voice number from any phone and see that it rings through to your browser. Then sign out of chat.
Get it started
With these settings in place, Asterisk should be listening to FreeSWITCH on 127.0.0.1 port 5060, and FreeSWITCH should be listening to Asterisk on 127.0.0.1 port 5050. Furthermore, FreeSWITCH should be able to navigate a NAT and talk to the Google Talk server and, using the latest FreeSWITCH code, send and receive calls on the Google Voice number.
/usr/local/freeswitch/bin/freeswitch -c will give you a console and once you have worked out the bugs, you can run it in the background with
Does it work?
Let me know if you have followed these instructions and achieved success. I was able to send and receive calls with Google Voice, with working DTMF and mostly acceptable audio quality.
Place test calls with
dl_debug on in the FreeSWITCH console to see the XMPP messages. I spent a lot of time examining these and Wireshark captures to find RTP issues (solved in the config and with the firewall adjustments).
I was disappointed that the audio was sometimes jittery, which I never see with the Gizmo5 or PSTN Google Voice transports. I don’t know if it was from the Internet or from the server itself, but I can say that FreeSWITCH in this very minimal mode seems to add very little additional memory or CPU usage.
<!– <action application=”answer” /> Add this to answer the call before bridge to * –>
<!– <action application=”ring_ready” /> Or GV Voicemail will get it if you don’t ans. –>
<!– <action application=”set” data=”ringback=%(2000, 4000, 440.0, 480.0)” /> –>