[asterisk-users] NAT and Dial to two channels at once

Brad Templeton brad+aster at templetons.com
Sun Dec 10 02:11:30 MST 2006


We all love Asterisk's ability to Dial(chan1&chan2) and take the first that
answers.

However, I have been encountering a problem when one of the channels
is an external phone behind NAT and another is a local phone on the
same net as the asterisk server.

All have canreinvite=yes, and the phone behind NAT is correctly
using Stun to give its external ports, which are opened to it
in the firewall, in addition.

When an incoming call comes in for the extension, and it is
sent to a plain old Dial(SIP/chan1) it works -- two way audio,
native bridged.  All happy.  When it's Dial(SIP/outside&SIP/inside)
and the outside channel answers, bad news.

Here's what happens.

a) The invite comes in from DID with DID-SDP.

b) Asterisk sends out two invites, one to SIP/outside and another to
SIP/inside.  However, it put an Asterisk server SDP in the
invite to SIP/outside instread of DID-SDP.

c) The phone answers, and provides asterisk with Outside-SDP.
The phone however got an invite that makes it think it should
be sending audio to Asterisk-SDP, which it does, where I think
it's discarded, as I don't hear it.

d) The DID should be sending audio to the outside phone but
I'm not hearing that either.  (Not sure why as this SDP looks
fine.)


Note that if I press 'hold' on the outside phone, Asterisk
starts music on hold and the caller to the DID hears it.
Press hold again and -- bingo -- the audio is now working.


So, the solution to this long term is that Asterisk needs
to either send a reinvite to the target phone after it answers,
to properly connect its audio with the source, or asterisk has
to decide to locally bridge the audio, and send each endpoint
only an Asterisk SDP.

Any good ways to make this happen, or do we just have to
hope for a fix?


(This may be getting complicated by the inside phone
being on a different network interface, an internal LAN,
while the outside phone is reached via the external
internet.)


More information about the asterisk-users mailing list