[Nexus 4 General] ivan.net:
So, I have been trying to setup my own EC2 with Asterisk 11 as well. This thread is so informative!

I ran into several of the problems described in this thread and did some debugging as well. Let me share my solutions. Two things:

1) NAT related problem reported earlier. Specifically, UDP works but TCP doesn't. TCP would register but when GV incoming calls is received and asterisk calls the SIP (nexus 4) phone, SIP software doesn't seem to receive/ACK and thus won't ring. Again, UDP works, TCP doesn't.

For this, in short, the solution is to change to a port other than 5060 AND add a few more lines for NAT.

Here is my sip.conf

[general]
allow=all
allowguest=no
nat=force_rport,comedia
[B]udpbindaddr=0.0.0.0:5070
externudpport=5070
tcpbindaddr=0.0.0.0:5070
externtcpport=5070
[/B]tcpenable=yes

externhost=ELASTICIP
localnet=10.0.0.0/8
; I think the line below is optional but I added it anyway
media_address=ELASTICIP

[USERNAME]
; for me, if this is peer, it won't allow outgoing call from CSS
type=friend
; also optional
defaultuser=USERNAME
secret=PASSWORD
host=dynamic
; I have multiple accounts for outgoing calls so I customized this, make sure it matches in extensions.conf
context=outgoing-USERNAME
transport=udp,tcp
; this is to avoid a warning message in the asterisk log about user with no mailbox
mailbox=no

Explanations: The problem seems to be both NAT related and port related. See a recent thread

groups.google.com/d/topic/csipsimple-users/Mc7-oUS2vZg/discussion

attributing the problem to an Android conntrack optimization on 5060 that aims to improve SIP connection stability but somehow breaks things. That's why doing only either nat command or special port alone won't solve the problem. So, I changed to a non-standard port. remember to use externtcpport or it won't work with NAT somehow. Without that, I see from sip debug that many of the messages continue to be targeting the default port of 5060. Possible symptoms if you do not do this is your signaling won't work: cannot hangup on the CSS side, it won't ring/receive calls, etc.

So, now my setting works very well. CSS configured to use TCP, on port 5070. Tested on T-Mobile Cell, WiFI behind NAT, and WiFi without NAT (with a direct/public IP). Note, all these I didn't use PPTP/VPN, which, I believe, in addition to providing encryption also avoid a lot of NAT stuff.

2) The other thing is to enable multiple GV/outgoing accounts. jhax01 posted the config for extensions that will do that trick. Specifically, by added "*" in front of the number when you call to use another outgoing account.

In my Asterisk 11, it does not automatically ignore the "*" sign and actually passes it through. So, I changed the extension.conf settings under [local] as follows (yours should read [local], but I customized it):

[outgoing-USERNAME]
exten => _1XXXXXXXXXX,1,Dial(Motif/gv1/${EXTEN}@voice.google.com,,r)
exten => _XXXXXXXXXX,1,Dial(Motif/gv1/${EXTEN}@voice.google.com,,r)
exten => _+1XXXXXXXXXX,1,Dial(Motif/gv1/${EXTEN}@voice.google.com,,r)
exten => _+XXXXXXXXXXX,1,Dial(Motif/gv1/${EXTEN}@voice.google.com,,r)
exten => _*1XXXXXXXXXX,1,Dial(Motif/gv2/[B]${EXTEN:1}[/B]@voice.google.com,,r)
exten => _*XXXXXXXXXX,1,Dial(Motif/gv2/[B]${EXTEN:1}[/B]@voice.google.com,,r)
exten => _*+1XXXXXXXXXX,1,Dial(Motif/gv2/[B]${EXTEN:1}[/B]@voice.google.com,,r)
exten => _*+XXXXXXXXXXX,1,Dial(Motif/gv2/[B]${EXTEN:1}[/B]@voice.google.com,,r)

The code is to add ":1" to ${EXTEN} so that it skips the first char "*".