yashsingh1/xdaforums huggingface dataset:
[Nexus 4 General] swaggerwocky:
Call from '' (x:39078) to extension 'x' rejected because extension not found in context 'home'

This is what I see in asterisk CLI when I try to place a call from my phone, not sure how to resolve this. Any help would be appreciated!
[Nexus 4 General] bluespire:
What is the reason for changing the port #? If your security allows only your phone, why does it matter?

"Security through obscurity is no security at all."

-I forget who said this.
[Nexus 4 General] errorcod3:
Does it say x, or did you edit that?
[Nexus 4 General] swaggerwocky:
I edited the IP and number called out.
[Nexus 4 General] errorcod3:
It prevents people from catching your server if they are dong massive sweeps of IP addresses for specific ports. If someone was targeting the server, this would only slow them down -- a full port scan would find it anyway.
[Nexus 4 General] errorcod3:
Why does it say context 'home'?

Are you using different conf files that what I supplied?
[Nexus 4 General] swaggerwocky:
I've copied and pasted everything exactly from your OP into the conf files you listed, starting from an empty file after backing up the original files.

This is the conf that references 'home'.

#sip.conf

#pay attention to externhost, localnet, and secret

[general]
context=home
callerid=Unknown
notifyringing=yes
notifyhold=yes
tos_sip=cs3
tos_audio=ef
tos_video=af41
alwaysauthreject=yes
disallow=all
allow=ulaw
allow=alaw
allow=gsm
callevents=no
jbenable=no
maxcallbitrate=384
maxexpiry=3600
minexpiry=60
notifyhold=yes
notifyringing=yes
registerattempts=0
registertimeout=20
rtpholdtimeout=300
rtpkeepalive=0
rtptimeout=30
srvlookup=no
t38pt_udptl=no
checkmwi=10
videosupport=no
canreinvite=no
allowguest=yes
defaultexpiry=120
g726nonstandard=no
nat=yes

externhost=ELASTICIP
localnet=IFCONFIG_ADDRESS/255.255.255.192

[USERNAME]
;type=friend
type=peer
username=USERNAME
secret=PASSWORD
host=dynamic
context=google-out
[Nexus 4 General] errorcod3:
Then it should say content 'google-out', not home. Did you copy your new files to /etc/asterisk? make sure they are named correctly. The file that is suspect is /etc/asterisk/extensions.conf

If should have three main headers titled:

[general]

[google-out]

[google-in]

Does it have that? If so, try restarting the asterisk server.

/etc/init.d/asterisk stop

/etc/init.d/asterisk start
[Nexus 4 General] swaggerwocky:
Yep, I've made sure they're named correctly and in the correct location. The 'home' reference is regarding the sip.conf file under [general]. I changed the context=home to context=google-out and the change was reflected in that error message I received.

[Feb 1 23:17:14] NOTICE[1101][C-00000001]: chan_sip.c:25184 handle_request_invite: Call from '' (72.x.x.x:39078) to extension 'xxxxxxx' rejected because extension not found in context 'google-out'.
[Nexus 4 General] errorcod3:
Ok, something is screwy with your sip.conf, does your user section look like this:

[YOURUSERNAME]
type=peer
username=YOURUSERNAME
secret=PASS
host=dynamic
context=google-out
transport=udp,tcp
[Nexus 4 General] errorcod3:
the context section under general in the sip.conf doesn't really matter because it gets overridden by the context=google-out under the user section.
[Nexus 4 General] errorcod3:
Also try this, just to see if you forgot to change some of the USERNAME entries:

cd /etc/asterisk
cat * |grep USERNAME

You should get :

/etc/asterisk$ cat * |grep USERNAME
; [username@domain] ; Has to be unique within domain (MWM_USERNAME, MWM_DOMAIN)
;setvar => DB_CIDNAME=${ODBC_CID_NAME_LOOKUP(${USERNAME})}
; USERNAME (username)

and no more...
[Nexus 4 General] swaggerwocky:
Yes, like I said earlier I C+P'd straight from your OP and edited the fields you stated. I've no idea what I'm missing.
[Nexus 4 General] errorcod3:
in the extensions file you should see:

[google-out]
exten => _1XXXXXXXXXX,1,Dial(Motif/USERNAME/${EXTEN}@voice.google.com,,r)

Make sure that USERNAME entry matches the rest of your USERNAME entries...
[Nexus 4 General] swaggerwocky:
Ran the grep USERNAME and only saw what you said I should see. I will go over all the confs again and make sure my username is the same in all of them (I used the shortcut you listed on page 3 regarding changing all the USERNAME).

Everything checks out, no idea what the issue is. I'll delete the confs and start from scratch without resorting to the renaming shortcut.
[Nexus 4 General] acegolfer:
It only makes it a little harder for the hackers. Since I can now hangup the phone normally on 5060 port, I'm going to use port 5060.

How do you only allow your phone? In addition to Tmo 3g and my home wifi, I also use 5+ other wifi hotspots regularly.
[Nexus 4 General] swaggerwocky:
Remade the confs and back to the same error message. Could it be something I've set in CSS?
[Nexus 4 General] errorcod3:
Do you have any filters setup in CSS? If so, that could be problem. Also, try put a 1 in front of the number you are dialing. You have to use ten digit dialing with a 1 prefix..
[Nexus 4 General] swaggerwocky:
No filters, and I've tried dialing with 1 as a prefix. I can't figure out the issue is, SIP registers but '404 / Not Found' whenever a call is placed. I guess I'll keep messing around with things.
[Nexus 4 General] errorcod3:
what codec are you using? try disabling everything but ulaw and try again.
[Nexus 4 General] errorcod3:
disabling everything in CSS, not on the server.
[Nexus 4 General] swaggerwocky:
I assume ulaw is PCMU under CSS' codec list? That's all I have enabled.
[Nexus 4 General] errorcod3:
Yep, it is. So strange -- would you be willing to use pastebin.com and put in your config files (just the ones you created)? Edit out your google account and SIP password? I would have to see everything to see what is going on. Also, show me the output of "sudo ufw status" and "iptables --list". Double check your security group on EC2 and make sure those ports are configured correctly.
[Nexus 4 General] errorcod3:
Also, one other thing that isn't too clear in my OP.

in sip.conf, the entry that looks like this:

externhost=987.654.321.001
localnet=123.456.789.001/255.255.254.0

The externhost is your Elastic IP.

The localnet is derived from running:

ifconfig

eth0 Link encap:Ethernet HWaddr
inet addr:123.456.789.001 Bcast:123.456.789.255 Mask:255.255.254.0
inet6 addr: Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:28459 errors:0 dropped:0 overruns:0 frame:0
TX packets:17157 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:40013358 (40.0 MB) TX bytes:1775646 (1.7 MB)

inet addr: is the localnet IP address and Mask is what you enter after the /
[Nexus 4 General] errorcod3:
I was able to reproduce your problem... more to follow.
[Nexus 4 General] errorcod3:
Well, I didn't figure much out yet. Here's what I did. I started a new instance on us west (California) and followed my instructions to the T. Using UDP I was able to make a call. I switched everything to TCP and I started getting the same error as you.

It's strange, because I have the same EXACT setup on us west (Oregon) and everything works fine. To confirm this I copied my conf files from my working server to the one in California -- and it didn't work.

I have no idea what is causing this. But, I'll keep working on it. Sorry it's not working for you.

Can you confirm UDP calls work?
[Nexus 4 General] errorcod3:
I found a solution, but I have no idea why it works.

in sip.conf change context=home to context=default

in extensions.conf add:

[default]
exten => _1XXXXXXXXXX,1,Dial(Motif/USERNAME/${EXTEN}@voice.google.com,,r)

Make sure you change the USERNAME part... let me know if it works for you -- worked for me..
[Nexus 4 General] swaggerwocky:
Thanks, going to give this a shot.
[Nexus 4 General] acegolfer:
Errorcode,

Thanks for the help and an excellent guide. I've learned a lot here.

I've settled with PIAF on EC2 for now because it's easier to manage 3 GV numbers + 6 phones.
[Nexus 4 General] jhax01:
Hey, thanks a bunch for this guide! I've been using talkatone when traveling overseas but it hasn't been the best at capturing inbound calls on 3G for me. Based on how well the server is performing right now, I'm hoping this will do the trick on my next trip.
[Nexus 4 General] errorcod3:
I travel overseas as well. Which is why I like Amazon. You can setup a instance in Europe or Asia and your setup will work great.
[Nexus 4 General] jhax01:
Of course, inexplicably, I am no longer able to receive calls either via wifi or 3g?!?!? I can dial out just fine. Is there a way to watch and debug the connection in real time? Or just dig through the logs? I reinstalled Talkatone briefly to see if it was a Gtalk issue, but it worked fine.
[Nexus 4 General] errorcod3:
as root type asterisk -rvvv then call yourself and you can see what's going on.
[Nexus 4 General] acegolfer:
If you can make calls but occasionally cannot receive calls, then the asterisk server may think your phone is unreachable. Go to asterisk CLI and "sip show peers." Your phone extension will show as "unreachable."

Why does this happen? "qualify=yes" This means asterisk server will check your phone is connected every "qualifyfreq" (default = 60 seconds). If the phone doesn't respond, then asterisk will consider your phone "unreachable" and will not ring your phone until the phone reconnects again. You will have to play with qualifyfreq and sip client's keep-alive interval so that asterisk and phone are connected all the time.
[Nexus 4 General] jhax01:
Well, I've been playing around with it quite a bit and have come up empty. sip show peers gives this result:

Name/username Host Dyn Forcerport ACL Port Status Description
xxxxxx/xxxxxx 216.196.175.235 D A 40303 OK (98 ms)

So the sip client is connected. It just doesn't get rang when a call comes in. I had everything working nicely, but then mucked things up a bit and decided to rebuild everything from scratch again and ended up in this boat. I followed everything exactly in the same fashion. I almost think that something was committed to asterisk between my first attempt and this one that changed syntax or something. I'm usually good at details but this one is escaping me....
[Nexus 4 General] jhax01:
Ok, so now I know more about Asterisk then originally planned, but that 's not a bad thing...lol. I'll share a few of my findings to hopefully help others who give this a try.

I did a lot of chasing to figure out what was wrong with my inbound calls, but as it turns out the solution was very simple. The short version is that my inbound call issues were tied directly to the Gtalk server. Setting Asterisk's priority to "1" made sure it was dead last when it came to initiating any inbound connections whatsoever. And, in fact, any inbound calls would terminate at the Gtalk server and never even hit Asterisk's horizon. It all worked initially for me because I wasn't logged in anywhere at first, but when I booted up the N4, it auto logged into Gtalk. So, if you're using a dedicated email/voice acct, you may not run into this issue, but for me, the fix was as simple as setting the priority in XMPP.conf to 100. Just FYI - A side effect of this is most likely to be that now all inbound connections terminate at Asterisk and Gtalk doesn't get a chance at them.

As a cautionary item, setting sip.conf to allow guests is a bit dangerous unless you define their limitations or are on a local network behind a hardware firewall. The current one is written in this guide will allow *anyone* to utilize your PBX and by extension, your google voice account. If your GV account is set to auto refill with $$....well, you get the idea... Additionally, for this particular application, most of the parameters specified in the [general] section of sip.conf aren't needed. Just specify the no guest thing and any protocols you would like to use.

There is also some danger to use the [default] section in extensions.conf if you are trying to operate privately as Asterisk will look there to dial whenever it receives an undefined request. This again exposes you to potential mischief.

One other tip is on your outbound calls you can define multiple formats so you don't have to change the way you normally dial, in addition to local calls, like so:

exten => _1XXXXXXXXXX,1,Dial(Motif/USERNAME/${EXTEN}@voice.google.com,,r)

** this covers dial requests formatted as 1-555-444-1234

exten => _XXXXXXXXXX,1,Dial(Motif/jhaxgvsip/${EXTEN}@voice.google.com,,r)

** this covers dial requests formatted as 555-444-1234

etc, etc....

Thanks again, errorcod3! I never would have even attempted this if it weren't for your guide! :D
[Nexus 4 General] errorcod3:
Great info! If you post your sip.conf I'll modify the OP.
[Nexus 4 General] swaggerwocky:
errorcod3, thanks for your guide and your help with getting TCP working. I finally got around to setting things up properly today while I wait for my number to be ported over to Google Voice. If I want to utilize Simonic's GVGW (https://simonics.com/gvgw/) with your setup, what modifications should be made? As far as my understanding goes, I should add a 'register => (Simonic's gvgw info)' under sip.conf [general] and modify xmpp.conf to connect to GVGW instead of GV. I plan to do some more reading to understand the changes I should make in order to get this working after I get some chores out of the way.

edit: If I'm correct with the use of GVGW, xmpp.conf and motif.conf are not utilized at all and I just need to modify sip.conf and extensions.conf. So the setup would be: CSS>registers with GVGW ---- Asterisk>registers with GVGW. I think I've made the necessary adjustments to sip.conf:

register => GVxxxxxxxxxxx:password@gvgw4.simonics.com/xxxxxxxxxxx

[gvgw]
host=gvgw4.simonics.com
username=GVxxxxxxxxxxx
secret=password
type=peer
qualify=yes
qualifyfreq=240
insecure=port,invite
context=from-trunk

I'm not too sure if my extensions.conf is correct:

[from-trunk]
exten => _1XXXXXXXXXX,1,Dial(SIP/${EXTEN}@gvgw)

I'm still waiting for my number to finishing porting over to GV so I'm not sure if in/out works yet. I'm able to dial out a number but after the receiver picks up the call it just hangs up (I'm assuming GVGW is attempting to dial the number I specified during the sign up which is still in the process of being ported, so the call isn't successfully bridged).
[Nexus 4 General] jhax01:
@burndtjamb - Hey, so what's the advantage of using Simonic's GVGW? As far as I can tell, it only accomplishes what chan_motif does in Asterisk? Just curious.
[Nexus 4 General] acegolfer:
Some people claim that simonics is more reliable than asterisk GV module and chan_motif. Haven't verified it myself though.

In fact, I use both in my PIAF. If I call a 10 digit number, GV module places the call. If I call a 1+ 10 digit number, then GVGW (w/ a different GV number). No difference in call quality (tested with 2 N4's side by side).
[Nexus 4 General] swaggerwocky:
In addition to what acegolfer said:

As far as I know, it simplifies the process of using GV with VoIP devices. It also has Caller ID name lookup for incoming calls through your GV number, but I believe it's possible to add that functionality to Asterisk. If anything, I'm just enjoying the learning process involved with messing around with different Asterisk configurations B)
[Nexus 4 General] errorcod3:
Nice! I updated the OP to include your config files. They work well for me. I'm still learning Asterisk myself, it's a pretty cool program.
[Nexus 4 General] errorcod3:
I'm not exactly sure how to correctly add simonics, I don't use it. I think acegolfer uses it, maybe he knows.
[Nexus 4 General] errorcod3:
If you get TLS working, post it and I'll add it. A few other things I'm working on:

1. Adding ability to record all calls on the server side.

2. A automated script that will walk thru the install process.
[Nexus 4 General] bluespire:
Does anyone know how to prevent android from asking me if I want to use SIP or Mobile on EVERY call? My phone bogs down on nearly outgoing call while it runs some checks and then asks me which method to make the call.
[Nexus 4 General] acegolfer:
I use simonics as a back up in my PIAF but haven't researched how to configure it manually in asterisk. Almost everything in PIAF is configured by web GUI. For those who don't know, PIAF is combo of asterisk engine + freepbx interface + other modules/programs.

One day, I'd love to learn more about asterisk. But for now, getting PIAF to perfection is a priority.

---------- Post added at 12:09 PM ---------- Previous post was at 12:08 PM ----------

If you use csip, then use filters.
[Nexus 4 General] errorcod3:
Mine is setup like this, I have google voice configured to "use for every call". Then I have CSS configured "Integrate with Android". When I make a call from the dialer I get a pop up that says "CSS or Mobile" if I pick CSS it uses SIP, if I pick Mobile it uses google voice. I'm using the CSS nightly build which works nicely with the Nexus 4. http://nightlies.csipsimple.com/trunk/

If you don't want it to ask you, then I think you need to turn off Integrate with Android and then it will just use your cell to make all calls.

Here's what it looks like when I make a call:
[Nexus 4 General] bluespire:
Ah, this is csip prompting me!? I thought it was Android System.

---------- Post added at 12:01 PM ---------- Previous post was at 11:57 AM ----------

I think you misunderstand. I want the opposite of that. I want it to stop prompting me to use my mobile and ALWAYS use sip. This way I can test the system better. My goal is to drop my minutes, which is an extra $40-$50 a month. Data is only $30.
[Nexus 4 General] errorcod3:
Call Recording:

This worked for adding call recording. All calls are recorded and saved to: /var/spool/asterisk/monitor

replace extensions.conf with this (Don't forget to change USERNAME on last line):

[general]
autofallthrough=yes

[default]
exten => 411,1,Answer()
same => n,Dial(Motif/google/18003733411@voice.google.com)

[local]

exten => _1XXXXXXXXXX,1,Set(MONITOR_FILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${EXTEN:1})
same => n,MixMonitor(${MONITOR_FILENAME}.wav,W(1))
same => n,Dial(Motif/google/${EXTEN}@voice.google.com,,r)

exten => _XXXXXXXXXX,1,Set(MONITOR_FILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${EXTEN:1})
same => n,MixMonitor(${MONITOR_FILENAME}.wav,W(1))
same => n,Dial(Motif/google/${EXTEN}@voice.google.com,,r)

exten => _+1XXXXXXXXXX,1,Set(MONITOR_FILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${EXTEN:1})
same => n,MixMonitor(${MONITOR_FILENAME}.wav,W(1))
same => n,Dial(Motif/google/${EXTEN}@voice.google.com,,r)

[incoming-motif]
exten => s,1,NoOp()
same => n,Set(crazygooglecid=${CALLERID(name)})
same => n,Set(stripcrazysuffix=${CUT(crazygooglecid,@,1)})
same => n,Set(CALLERID(all)=${stripcrazysuffix})
same => n,Set(MONITOR_FILENAME=${STRFTIME(${EPOCH},,%Y%m%d-%H%M%S)}-${stripcrazysuffix})
same => n,MixMonitor(${MONITOR_FILENAME}.wav,W(1))
same => n,Dial(SIP/USERNAME,20,D(:1))

if you want to convert the wav files to mp3. Then you'll need to add lame support

sudo su
echo "deb http://ubuntu.mirror.cambrium.nl/ubuntu/ lucid main multiverse" >> /etc/apt/sources.list
apt-get update
apt-get install lame

Put the following script in /var/spool/asterisk/monitor and run it when you want to convert the WAV to MP3 (saves space):

#!/bin/sh
# name of this script: wav2mp3.sh
# wav to mp3

for i in *.wav; do
if [ -e "$i" ]; then
file=`basename "$i" .wav`
lame -h -b 192 "$i" "$file.mp3"
fi
done

Don't forget to restart asterisk. I set a cron to run the script at midnight and tar zcvf the files with the days date. One tgz file for each date...
[Nexus 4 General] bluespire:
Awesome. Now how do we send those files to dropbox to save space. I suppose a script could be set to just rotate the files out after say 30 days. I would think by then you would know if you needed to keep one.
[Nexus 4 General] errorcod3:
I use Amazon Glacier (http://aws.amazon.com/glacier/). The cost is 1 cent for 1 GB per month. 1GB of phone calls is a lot of phone calls.. so roughly 12 cents a year to store my phone calls.

Dropbox would be easy to setup as well. Try this: https://github.com/andreafabrizi/Dropbox-Uploader
[Nexus 4 General] Antebios:
I already have an Ubuntu server at home that I use for other "home" personal stuff. It's already facing to the world and I use with Subsonic and other things. I already have Asterisk installed, but I don't think I have it configured properly. Does anyone have a guide for Ubuntu server at home, or is this guide good enough?
[Nexus 4 General] errorcod3:
If you already have Asterisk installed (with the proper modules), then just replace the config files mentioned in this guide.
[Nexus 4 General] jhax01:
Nice, nice, nice....

Haven't been able to get TLS working over SIP, but I did add an IAX channel which allows md5 and rsa authentication out of the box. Apparently IAX coupled with G729 has much lower latency and bandwidth requirements than a SIP connection. Call quality has been very good for me, but I haven't had a truly dodgy connection to know how well it works. The only drawback is that it is UDP, so there is potentially the battery issue if your keep alive intervals are short. Set up couldn't be simpler, all that needs to be done is to mod iax.conf like so:

iax.conf

[general]
autokill=yes
allow=all
jitterbuffer=yes

[USERNAME]
type=friend
auth=md5,rsa
secret=YOURPASSWORD
host=dynamic
context=local

USERNAME and YOURPASSWORD obviously need to be different than the ones used in sip.conf. context=local points the outbound calls @ the google voice extensions. Now the only other thing to do is add inbound support in extensions.conf:

extensions.conf

same => n,Dial(IAX2/IAXUSERNAME,20,D(:1))

Add the above line just underneath the last line under [incoming-motif] in extensions.conf.

You will also need to open port 4569/udp in your security group as well as ufw.

After modding, you may need to reboot the EC2 server to get the IAX channel functioning properly. Simply restarting Asterisk didn't work for me.

I'm using Zoiper as an IAX client. Now on an inbound call, Asterisk will ring both the SIP and IAX client concurrently. Obviously you don't want to be logged in to both on the same phone at the same time as you will get a double ring.

I also have multiple Google Voice numbers via the same client functioning. Inbound calls from any number of GV#s ring the phone just fine. Selection of which number to use for the outbound calls is made through some case management of the exten commands. It seems that Asterisk is willing to ignore the * and + sign...so one, both, or a combo is used to select the outbound phone line. I'll post up what I have tomorrow. The only thing that is lacking is parsing the inbound call to show which phone line is being used. I'm sure someone around here will be able you figure that out quite easily.