No voice external calls - Asterisk 1.8.13 on Ubuntu 12.10

Hi,

I have a problem with NAT configuration and after searching for hours on the Internet, I went here to check if the community can help me. I have two phones, one configured with X-Lite, connected to the local network, behind the NAT and the other is my phone, an Android 4.2.2 Galaxy S2 using the Phone.apk internal SIP client to connect on my server. My phone is using its own data connection and is not connected to my local network.

My first test was to check if voice was correctly working locally. I then enabled WiFi on my phone and I dialed the extension 1001 (which is my soft phone on my computer, X-Lite). My soft phone receives the call, I answered it and I could perfectly hear myself. I tried the same thing, keeping my phone connected to my local network using WiFi but reversely (X-Lite calls Android phone). Everything was working too. I can hear my own voice on both device, we can talk on both devices, everything is working.

There is the problem. I disabled my phone WiFi adapter so it will work externally from my local network. I’ve repeated the SAME exact steps from my first test. I was able to receive the request on both phones. I could refuse the call, or accept it, this process is working perfectly. The thing is, I don’t receive ANY voice input. Both devices are connected, but they can’t receive or send voice. Ending a call ends normally. It’s like Asterisk things everything’s went OK.

My local network is ranged at 192.168.1.0/24. NAT translation is done by my router at 192.168.1.1. Port forwarding is already configured. I’ve opened 5060 UDP and 10001-20000 UDP. My X-Lite phone is connected using the local IP address 192.168.1.50. The Asterisk server is hosted using the local IP address 192.168.1.40. I don’t have a static external IP address, my ISP is addressing this by DHCP. I’m using VoIP.ms to redirect external calls, but this isn’t part of this topic. I’m configuring “internal” calls using home made extensions like 1000 and 1001. Just to be clear, I want every devices to be able to connect on the server and receive / make calls from anywhere. Implying everything is working locally, I don’t think it would be a codec problem or some sort, because otherwise I would be facing this issues while trying my calls locally. Here’s my configuration files:

sip.conf

[code][general]
bindaddr=0.0.0.0
localnet=192.168.1.0/255.255.255.0
externhost=mydynhost.dyndns.org
externrefresh=10
matchexternaddrlocally=no
nat=yes
register => user:****@montreal.voip.ms:5060
registertimeout=15
registerattempts=0

[voipms]
canreinvite=no
context=voipms
host=montreal.voip.ms
secret=****
type=peer
defaultuser=user
disallow=all
allow=ulaw
fromuser=user
trustrpid=yes
sendrpid=yes
insecure=invite
nat=yes

[1000]
type=friend
context=phones
host=dynamic
defaultuser=1000
secret=****
nat=yes

[1001]
type=friend
context=phones
host=dynamic
defaultuser=1001
secret=****
nat=yes
[/code]

extensions.conf

[code][phones]
include => internal
include => voipms

[internal]
exten => _1XXX,1,Answer()
exten => _1XXX,n,Dial(SIP/${EXTEN})
exten => _1XXX,n,Hangup()

[voipms]
include => voipms-inbound
include => voipms-outbound

[voipms-outbound]
exten => _1NXXNXXXXXX,1,Dial(SIP/${EXTEN}@voipms)
exten => _1NXXNXXXXXX,n,Hangup()
exten => _NXXNXXXXXX,1,Dial(SIP/1${EXTEN}@voipms)
exten => _NXXNXXXXXX,n,Hangup()
exten => _011.,1,Dial(SIP/${EXTEN}@voipms)
exten => _011.,n,Hangup()
exten => _00.,1,Dial(SIP/${EXTEN}@voipms)
exten => _00.,n,Hangup()

[voipms-inbound]
exten => somenumber,1,Answer()
[/code]

Thanks for any further help!
Dave

hi:
please show the CLI logs.

Hi,

Do you prefer some more specific logs from the CLI? By default, not much is shown:

== Using SIP RTP CoS mark 5 -- Executing [1001@phones:1] Answer("SIP/1000-00000099", "") in new stack -- Executing [1001@phones:2] Dial("SIP/1000-00000099", "SIP/1001") in new stack == Using SIP RTP CoS mark 5 -- Called SIP/1001 [Apr 11 03:30:44] NOTICE[17429]: channel.c:4169 __ast_read: Dropping incompatible voice frame on SIP/1000-00000099 of format ulaw since our native format has changed to 0x2 (gsm) -- SIP/1001-0000009a is ringing -- SIP/1001-0000009a answered SIP/1000-00000099 -- Remotely bridging SIP/1000-00000099 and SIP/1001-0000009a == Spawn extension (phones, 1001, 2) exited non-zero on 'SIP/1000-00000099'

Thanks
Dave

You have an external bridge between 1000 and 1001. What happens if you disable direct media (directmedia=no (also change canreinvite to directmedia in other places, as canreinvite is a deprecated name))?

nat= is over used. Are 1000 and 1001 really on public addresses?

If you have problems after disabling direc media, you will need to “sip set debug on”, and provide the details of the SDP exchanged.

One of these extensions will often be used from public IP addresses. In fact about all of them excepts few ones. I’ll test the new settings when I’ll be at home.

Thanks

I didn’t know this simple instruction could make a big difference! :stuck_out_tongue:
Well thanks David, adding the instruction directmedia=no to the [general] section fixed the problem. I can hear and speak on both phones.

Here’s my configuration file for those who were looking for a solution over Google:
sip.conf

[code][general]
bindaddr=0.0.0.0
localnet=192.168.1.0/255.255.255.0
externhost=mydynhost.dyndns.org
externrefresh=60
directmedia=no
;disallow=all
;allow=ulaw
nat=yes
register => username:****@montreal.voip.ms:5060
registertimeout=15
registerattempts=0

[voipms]
directmedia=no
;canreinvite=no
context=voipms
host=montreal.voip.ms
secret=****
type=peer
defaultuser=username
disallow=all
allow=ulaw
fromuser=username
trustrpid=yes
sendrpid=yes
insecure=invite
nat=yes

[1000]
type=friend
context=phones
host=dynamic
defaultuser=1000
secret=****

[1001]
type=friend
context=phones
host=dynamic
defaultuser=1001
secret=****
[/code]

wiki.asterisk.org/wiki/display/ … +Avoidance

voip-info.org/wiki/view/Aste … anreinvite