PSU VoIP blog reader Oskar contributed an updated patch for GTalk shared status/invisible in Asterisk 11. You may recall that I hacked this functionality in to Asterisk 1.8. Oskar’s updates work the same way, now part of res_xmpp instead of the deprecated res_jabber. Thanks, Oskar!
Tag Archives: Google Voice
Asterisk on Amazon EC2 cloud; Google Voice update
Some quick updates on interesting topics featured on this blog.
VoIP news roundup
Some interesting VoIP-related news I read this week:
TAC to FCC: Set a Date Certain for the End of the PSTN – and the proposed year is 2018. The big concern seems to be maintenance of infrastructure when traditional landline subscribers are dropping off rapidly. I think that infrastructure still has a lot of value to it, but not necessarily for traditional telephone service. What could the utilities or private enterprise do with a copper grid and switching infrastructure that reaches even the most rural parts of the United States?
From the VoIP and Gadgets blog: How Skype Works With Facebook – an interesting interview about how Skype put their technology in the web browser for Facebook video chat. It’s basically the Skype client condensed down to a browser plugin.
Meanwhile, Google is doing it their own way with XMPP: Announcing Google+ Hangouts – Google keeps working at the XMPP extensions to make the protocol media-rich, and now they have group video chat. I don’t have a Google+ account and haven’t tried it out yet.
Google’s offering is standards-based: “To support Hangouts, we built an all-new standards-based cloud video conferencing platform.” And those standards are “XMPP, Jingle, RTP, ICE, STUN, SRTP” and “HTTPS + SRTP”. Some folks would say that it’s not “standards-based” unless SIP is doing the signaling. I think the only thing standard means today is that your work is published for others to use and some technical group of people reviews it. XMPP has that. SIP’s technical body is the IETF and H.323’s technical body is the ITU. Who’s more standard?
The standard with the most implementations wins (Betamax, anyone?) and Google has the weight to tip the end-user-connectivity scales toward XMPP/Jingle. SIP is firmly in place as the current IP trunking standard but might soon be falling behind when it comes to connecting the end-users.
Google killing off Gizmo5
I just received this e-mail stating that Google is killing off the Gizmo5 VoIP service they acquired in 2009:
Gizmo5 is writing to let you know that we will no longer be providing service starting on April 3, 2011. A week from today, March 11, 2011, you will no longer be able to add credit to your account.
Although the standalone Gizmo5 client will no longer be available, we have since launched the ability to call phones from within Gmail at even more affordable rates.
Thank you,
The Gizmo5 Team
Before Google’s purchase of Gizmo5, the SIP provider had a unique relationship with GrandCentral and then Google Voice that allowed a SIP connection (incoming only) to a Google Voice number. Until FreeSWITCH and Asterisk provided updated Google Talk modules last fall, Gizmo5 was the only way to have a purely VoIP connection to Google Voice.
Asterisk hack: make your Google Talk client invisible
It’s been a too-busy-to-write week, but I found some time the last few evenings to brush up my C coding (only hacking at this point, really) to make Asterisk 1.8 do something I’ve wanted from the beginning: Google Talk’s invisible mode for the Google Voice integration.
Quick background: Google wrote a variety of XMPP extensions to make Google Talk do voice and a bunch of other non-standard XMPP things. One of those things is what Google calls “shared statuses,” which also includes invisible mode–the ability to be online but set your client as invisible so that others can’t see you, but could chat with you.
You might want to use this feature if, like me, your Google Voice number is attached to your main GMail account. I don’t use the chat features but I appear online to anyone who has me in their contact list, as long as Asterisk is logged in, and that has the potential to draw unwanted instant messages (that will never get answered).
Note: I want to reinforce that this is a hack. The code is clean enough, but this is only useful for Google Talk and is only implemented as a set of Asterisk CLI commands. Furthermore, this functionality would probably never be implemented in Asterisk’s res_jabber because it’s Google-proprietary. On the other hand, if any Asterisk developers want to run with this, go for it! I don’t guarantee that this code will work for you and if your Asterisk process segfaults, stop using it.
Setup
Apply this patch against Asterisk 1.8.2.2’s (or trunk, currently) res/res_jabber.c by downloading the patch to your Asterisk source directory and running patch < res_jabber.patch
. You may have to tell it to apply the patch to res/res_jabber.c
.
Rebuild (or build) Asterisk. If you are rebuilding, just run make
after applying the patch. You should see make build the res_jabber module. Then make install
and restart Asterisk.
Usage
At the CLI, you can issue jabber set invisible on asterisk
to turn on invisibility for the Jabber connection named “asterisk.” If you don’t know what your Google Talk XMPP connection is called, just issue jabber show connections
and find out. You can set your connection visible again with jabber set invisible off asterisk
.
Now, here’s another thing that is really hacky: Google Talk only seems to apply the visibility/invisibility change if you are toggling. Here’s what I mean: if you were invisible, and logged out, then logged back in, Google still thinks you are invisible–but you’re not! So in that case, if you jabber set invisible on ...
, it doesn’t do anything, until you first set it off and then back on again. I think I know why this is happening and it has to do with res_jabber sending standard <presence> information at login rather than Google’s special shared-status presence scheme. If you want to be sure you are invisible, just start off by setting invisible off and then set it on. For me, that works every time. (I’d be grateful for someone who really knows all about this to fix it up and make it work right, the first time.)
References
I got the idea from this year-old blog posting about enabling Google Talk invisibility in Pidgin, which refers to the official documents published by Google on how it works.
Asterisk 1.8+Google Voice fixed
The Asterisk team released a small patch that fixes the protocol issue that was keeping Asterisk 1.8 users from dialing out through Google Voice.
patch
command before, it’s easy:- Go to the Asterisk bug tracker and get the attached file named fix
- Put it in your Asterisk source directory (the root, where the
configure
script, Makefile, and other such files exist). Call it gtalkfix.patch, to be a little less ambiguous. - From that same directory, run the command
patch < gtalkfix.patch
. If it says it can’t find the file to patch, specifychannels/chan_gtalk.c
. Oh, and if you don’t have the patch command, justyum install patch
first. - You should see something like this:
patching file channels/chan_gtalk.c
Hunk #1 succeeded at 193 with fuzz 2 (offset -3 lines).
Hunk #2 succeeded at 463 (offset -5 lines).
Hunk #3 succeeded at 1006 (offset -3 lines).
Hunk #4 succeeded at 1814 (offset -5 lines). - Now run
make
and you will see it compile chan_gtalk again. Of course, if you are applying it against the raw distribution, you’ll go through the entire build process. make install
and start Asterisk and you’ll be able to call through Google Voice again.
Asterisk 1.8+Google Voice broken; FreeSWITCH still works
As some folks commented, Google Voice seems to have stopped accepting outbound calls from Asterisk 1.8. There’s a bug report open with Asterisk on this issue, and several discussions in user forums.
I fired up FreeSWITCH again, without updating any code (still the source from mid-October, 1.0.head (git-dc40a77 2010-10-17 16-19-38 -0400)), and it works perfectly. Apparently, the FreeSWITCH guys are using a different method to make the Google Voice connection, or the Google folks are specifically filtering Asterisk or have made a change that affects Asterisk and to which FreeSWITCH is immune.
Adding Google Voice to FreePBX
If you’ve moved ahead to Asterisk 1.8 in production or are testing it out, use FreePBX as your configuration GUI, and want to add Google Voice such that inbound and outbound routing can easily be configured from FreePBX, here’s a small how-to. Unless and until a GTalk FreePBX module comes along, there’s some command-line work to do, but only for initial configuration.
References:
How To Add Google Voice To FreePBX
Part 1: In the shell
- Refer to the Asterisk Wiki: Calling Using Google. We’ll be following that as our guide.
- From the command line, as user root or asterisk, verify that the res_jabber and chan_gtalk modules are loaded.
[root@asterisk18 ~]# asterisk -rx "module show" | grep res_jabber
res_jabber.so AJI - Asterisk Jabber Interface 0
[root@asterisk18 ~]# asterisk -rx "module show" | grep chan_gtalk
chan_gtalk.so Gtalk Channel Driver 0- If one or both of those grep commands returns nothing, you need to build the modules (don’t forget to have OpenSSL development libraries installed) and make sure they are loading at Asterisk startup (
autoload=yes
ORload => res_jabber.so
andload=> chan_gtalk.so
in /etc/asterisk/modules.conf).
- There are three config files in /etc/asterisk to edit by hand (use
vi
,nano
,emacs
or whatever you like): jabber.conf, gtalk.conf, and extensions_custom.conf.- jabber.conf
Edit or replace jabber.conf to follow what is listed in Calling Using Google, and which I am pasting almost verbatim here. (I removed
debug=yes
.) This establishes the XMPP connection.[general]
autoprune=no
autoregister=yes[asterisk]
type=client
serverhost=talk.google.com
username=your_google_username@gmail.com/asterisk
secret=your_google_password
port=5222
priority=1
usetls=yes
usesasl=yes
statusmessage="I am an Asterisk Server"
timeout=100 - gtalk.conf
Again referring to the Asterisk wiki, edit gtalk.conf thus:
[general]
context=from-google
allowguest=yes
bindaddr=0.0.0.0
;externip=1.2.3.4 ; if you know your external ip addr
stunaddr=stun01.sipphone.com ; use STUN if you're on dynamic IP and NAT[guest]
disallow=all
allow=ulaw
context=from-google
connection=asterisk
Some notes about gtalk.conf:- Use context
from-google
, which we will set up in the extensions_custom.conf. connection=asterisk
must match the connection definition (in square brackets) in jabber.conf.- Use
externip
orstunaddr
to get your external IP address if you’re behind a NAT.
- Use context
- extensions_custom.conf
Make a section like this:
[from-google]
exten => s,1,Answer()
exten => s,n,Wait(2)
exten => s,n,SendDTMF(1)
exten => s,n,Set(CALLERID(num)=${CUT(CALLERID(name),@,1)})
exten => s,n,Set(CALLERID(name)=${CUT(CALLERID(name),/,1)})
exten => s,n,Goto(from-trunk,YOUR-GV-NUMBER,1)
exten => s,h,Hangup- Replace YOUR-GV-NUMBER with your Google Voice DID.
- The
Set
commands fix up the caller ID to get rid of the long XMPP ID that is passed on an inbound call.
- jabber.conf
- Once these files are in place, restart Asterisk (
amportal restart
). - Issue the following command to see that the XMPP connection to Google Talk has been established:
# asterisk -rx "jabber show connections"
Jabber Users and their status:
User: ...@gmail.com/asterisk - Connected
----
Number of users: 1 - Now you’re ready to set up a Google Voice trunk and inbound and outbound routes in FreePBX.
Part 2: FreePBX
- Add a new Custom Trunk.
- Trunk name: Google Voice
- Outbound Caller ID: put your Google Voice DID, even though this will be ignored (GV always uses your GV number for the outbound Caller ID)
- Dialed Number Manipulation Rules: Google Voice requires that the number be a full 11 digits, starting with 1. Either here or in your outbound route (or both), make sure you are sending a full 11-digit number. See the screenshot for my config.
- Custom Dial String: This is the most important part. Enter
gtalk/asterisk/+$OUTNUM$@voice.google.com
whereasterisk
matches the client definition in your jabber.conf (in square brackets). If you’ve followed this how-to exactly, then this line is correct. - Submit changes.
- Screenshot (click for full version):
- Add a new Outbound Route.
- Add a new Inbound Route.
- Refer back to this line you entered in extensions_custom.conf:
exten => s,n,Goto(from-trunk,YOUR-GV-NUMBER,1)
Whatever you entered for YOUR-GV-NUMBER will be the DID you use for your inbound route. - Description: Google Voice (or whatever you want)
- DID Number: YOUR-GV-NUMBER
- Other stuff: defaults
- Destination: wherever you want the incoming call to go. In my screenshot, it is directly dialing an extension.
- Screenshot (click for full version):
- Refer back to this line you entered in extensions_custom.conf:
- Submit all changes and apply configuration. Done! You have added a Google Voice two-way trunk to FreePBX and can use it in your inbound and outbound routing. Don’t forget to log in to Google Voice and select Google Chat (…@gmail.com) as the phone to which your incoming calls are forwarded!
Asterisk 1.8, FreePBX 2.8, and Google Voice on a Cloudy Day
This past weekend, I had a chance to test out all of the named technologies, all together–including the cloud.
The news last week was that Asterisk 1.8 connects directly to Google Voice via the Google Talk protocol. No more scripts or free DIDs to act as intermediary. And if you’ve set up GTalk with Asterisk on previous versions, it’s simple to go the extra couple steps and enable Google Voice.
Tested, and it works. Thanks to Michigan Telephone who drew my attention to the Asterisk wiki where the Google Voice setup is documented. If you’re already in a place where you can install Asterisk 1.8 and want to try it out, that wiki document will take you the whole way through it. (One note, however: I have allowguest=yes
, which is how this option is documented in the sample gtalk.conf, rather than allowguests=yes
, which is how it is documented in the wiki, and allowguest
[no s] works for me.)
While I am a huge fan of Google Voice, what was more interesting than getting that working this weekend was getting it running in the cloud–namely, Rackspace CloudServers. This was my venture into cloud VoIP, starting with dev/test, and partially out of necessity–I don’t have any more hardware at home to use for testing. I’ll give the end of the story first: it works nearly as well as my physical hardware setup at home in terms of audio quality and general calling functions, and an order of magnitude better for rapid deployment of a testing environment in which to set up the new versions of Asterisk and FreePBX. Naturally, I began to think: could I move my home PBX to the cloud? Not yet, and I have a number of technical reasons (not FUD) why, but I plan to try tackling them.
This is an introduction, and I know a number of folks stop by this blog looking for technical how-tos, so this week and next I will be digging into these topics: setting up Asterisk 1.8 and FreePBX 2.8, configuring Google Voice and nicely integrating into FreePBX (not just hacking it into the extensions_custom.conf by hand some config file editing required…), setting up a RS CloudServer for Asterisk, and some of the technical considerations I mentioned in the previous paragraph.
That’s a lot to write about, and I’ll get to it piece by piece. Meanwhile, if you want to just try it out (minus the cloud part), go get the latest Incredible PBX/PBX In A Flash from NerdVittles, install the ISO and have at it. They’ve gotten it working and bundled it together so that you can have a cutting-edge PBX… in a flash! But as for me and this blog, let’s just call it Asterisk PBX in a slow-cooker.
Using FreeSWITCH to add Google Voice to Asterisk
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
The steps:
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.
- Build:
./bootstrap.sh
- 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.
./configure
,make
, andmake 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-devel
for example). The make process will alert you of anything missing. Just install the requirements and thenmake
again, 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 samples
from 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.
Asterisk
- 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.0
to [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:
host=127.0.0.1
port=5050
qualify=30000
type=friend(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 appropriatecontext=
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.
Firewall
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.
Start FreeSWITCH. /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 -nc
instead.
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)” /> –>