Saturday, June 18, 2011

Asterisk and Android Gingerbread

OK, busy setting up an Asterisk server at home for a few experiments in VoIP.

What I want now?
  • Each DECT phone I have, connected via the A580-IP I mentioned on Twitter (it's a SIP-enabled DECT base station with some PBX-like functionality) to have an extension
  • Each SIP-capable mobile phone I have (ie my CyanogenMod Gingerbread phone with the built-in SIP client, and my wife's regular Android phone running something like Linphone) to also have extensions.
  • All phones to be capable of dialing one another
What do I ultimately want?
  • All extensions to be able to make internal and external calls
  • All extensions to "ring" when a SIP call comes in from my VoIP provider
  • My office extension to "ring" when a Google Talk call comes in (if such a thing is possible) for my business GMail account (which is linked to a Google Voice account.)
What do I have? Well, ultimately I figured out most of the first. Here are the gotchas I found.

1. Lots of redundant configuration

Asterisk requires extensions to be configured in two places: sip.conf, and extensions.conf. There's supposed to be a sip.conf option that automatically registers extensions (called regexten), but it doesn't actually seem to be useful - it registers the extension exists, but doesn't put in the rules necessary to call it. Strange. Asterisk seems to be so configurable that it wouldn't surprise me if there are things that can be configured to make it work, but for now, no dice. So, if you're playing with the system, remember to configure twice.

2. Make sure you get the realm right if you want Gingerbread clients to work

Android 2.3 Gingerbread turns out to have a fairly smart implementation of SIP, even though it's deceptively simple. I'd been experimenting with a different domain from the one actually used by the server (eg my address would be something like (but isn't), whereas the server itself is on sip.squiggleslash.internal port 5550.)

How's that supposed to work you might ask? Well, I figured it wasn't a problem because (a) I'd set up DNS properly (there's a SRV entry that points at the correct server and port) and (b) all SIP clients I'd come across let you specify the domain and server name seperately.

...except Gingerbread. Gingerbread doesn't ask you separately for the domain, merely asking you for the server, and that initially confused me, but it turns out the "server" Gingerbread is asking for is actually the domain. In other words, I entered

Username: squiggleslash
Password: 1234

And, FWIW, I entered the thing for the "outbound proxy" stuff, but I'm not sure that was necessary. The above was enough to get incoming calls (ie calls from any extension to the cellphone's SIP account) to work.

...but not outgoing calls. For outgoing calls, Gingerbread needs you to correctly configure the "realm" in your sip.conf, namely make it the same as the domain (ie in the above Otherwise you just get weird 404 errors in the Asterisk console.

Some of the above advice might be out of date. I'm using a three year old version of Asterisk that came with Ubuntu Hardy, which is the operating system I'm running on my VPS. But, whatever, the above is enough to mostly get everything working.

I'll let you know how I get on with the other tasks in the list...

No comments:

Post a Comment

Replies are welcome, but be aware comments are moderated. Be friendly, on-topic, and all of the things I'm not!