Brad Templeton
2006-Dec-10 02:11 UTC
[asterisk-users] NAT and Dial to two channels at once
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.)
Someone may have a more elegant solution, but I have found that allowing reinvite on a phone connected via NAT gateway causes too many problems, especially with the difference in the various NAT implementations. I set canreinvite=no host=dynamic nat=yes qualify=yes for all phones that connect from the Internet. A note to anyone doing Internet telephony -- the latest Linksys routers seem to ignore the small UDP keepalive that some phones like the grandstreams send, so the NAT hole closes. I've had to start using qualify=yes to get asterisk to keep the NAT hole open. -----Original Message----- From: asterisk-users-bounces@lists.digium.com [mailto:asterisk-users-bounces@lists.digium.com] On Behalf Of Brad Templeton Sent: Sunday, December 10, 2006 4:12 AM To: Asterisk Users Mailing List - Non-Commercial Discussion Subject: [asterisk-users] NAT and Dial to two channels at once 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.) _______________________________________________ --Bandwidth and Colocation provided by Easynews.com -- asterisk-users mailing list To UNSUBSCRIBE or update options visit: http://lists.digium.com/mailman/listinfo/asterisk-users