Re: [Doubango] Re: Call to SIPML5 crashes Asterisk after many 370401 errors

1,254 views
Skip to first unread message

Mamadou

unread,
Jan 15, 2013, 10:03:09 AM1/15/13
to doub...@googlegroups.com, Andrea Suisani, smiff...@gmail.com
Good that you fixed your issue but your diagnostic is not correct.
STUN server is only used to gather public IPs and it must be on public network.  If your STUN server is on the local network, this means the gathered addresses will be private.

On 1/15/2013 3:48 PM, Andrea Suisani wrote:
Hi all

Just one thing that have helped me to get media stream properly set up
between to instances of sipml5 on the same LAN whom the asterisk
server belongs to.

The problem: both sipml5 instance did not receive the audio stream,
because the clients use as stun server stun.l.google.com:19302 (hard coded
value), that is outside of your LAN and that's why the audio stream did not
"flow" properly between the callee and caller.
To solve it this what I've done.

Firstly  you need to install stun server inside your LAN, I did install
it on the same machine where asterisk is installed.

If you're using deb based system try "sudo apt-get install stun" to install it, 
then edit /etc/default/stun. Uncomment START_DAEMON=true, then set
PRIMARY_IP and SECONDARY_IP properly (use your server private IP
for the former and localhost for the latter)

Then start the stun server: sudo service stun start.

Then you have to edit sipml5 js code. I'm assuming you're
using a fresh checkout of sipml5 code
(see https://code.google.com/p/sipml5/source/checkout).

The files you've to edit are:

src/tinyMEDIA/src/tmedia_session_roap.js
src/tinyMEDIA/src/tmedia_session_jsep.js

This is the diff, just rember to use the IP address
of your stun server instead of 192.168.0.2:

Index: src/tinyMEDIA/src/tmedia_session_roap.js
===================================================================
--- src/tinyMEDIA/src/tmedia_session_roap.js    (revision 168)
+++ src/tinyMEDIA/src/tmedia_session_roap.js    (working copy)
@@ -80,7 +80,7 @@
         this.o_mgr.set_stream_local(__o_roap_stream);
 
         __o_session_roap.o_local_stream = __o_roap_stream;
-        __o_session_roap.o_pc = new __o_peerconnection_class("STUN stun.l.google.com:19302", __o_session_roap.__on_signaling_message);
+        __o_session_roap.o_pc = new __o_peerconnection_class("STUN 192.168.0.2:3478", __o_session_roap.__on_signaling_message);
         //__o_session_roap.o_pc = new webkitDeprecatedPeerConnection("NONE", __o_session_roap.__on_signaling_message);
         __o_session_roap.o_pc.o_session = __o_session_roap;
         __o_session_roap.o_pc.onstatechange = tmedia_session_roap.prototype.__on_state_change;
@@ -336,4 +336,4 @@
             __o_session_roap.o_mgr.set_stream_remote(null);
         }
     }
-}
\ No newline at end of file
+}
Index: src/tinyMEDIA/src/tmedia_session_jsep.js
===================================================================
--- src/tinyMEDIA/src/tmedia_session_jsep.js    (revision 168)
+++ src/tinyMEDIA/src/tmedia_session_jsep.js    (working copy)
@@ -315,7 +315,7 @@
         var This = this;
 
         // "__o_peerconnection_class" is equal to "webkitPeerConnection00 || webkitPeerConnection" on chrome and "w4aPeerConnection" on IE
-        this.o_pc = new __o_peerconnection_class("STUN stun.l.google.com:19302",
+        this.o_pc = new __o_peerconnection_class("STUN 192.168.0.2:3478",
                 function (o_candidate, b_moreToFollow) {
                     // tsk_utils_log_info("__on_ice_candidate: " + (o_candidate ? o_candidate.toSdp() : "null"));
                     if (o_candidate) {
@@ -617,7 +617,7 @@
     var This = this;
     if (!this.o_pc && !this.b_lo_held) {
         this.o_pc = new __o_peerconnection_class(
-                { iceServers: [{ url: 'stun:stun.l.google.com:19302'}] },
+                { iceServers: [{ url: 'stun:192.168.0.2:3478'}] },
                 this.o_media_constraints
         );
         this.o_pc.onicecandidate = tmedia_session_jsep01.mozThis ? tmedia_session_jsep01.onIceCandidate : function(o_event){ tmedia_session_jsep01.onIceCandidate(o_event, This) };

Once you did those changes you should be able to place
a call between two sipml5 clients without any audio problems.

Other things that could help you:

* I'm using asterisk 11.2.0 (released yesterday) built from
  source patched with:
 
  https://code.google.com/p/sipml5/source/browse/trunk/asterisk/asterisk_376131.patch

* both sipml5 client run inside google chorme version 25.0.1364.29 dev


Andrea

On Sunday, December 16, 2012 10:53:09 PM UTC+1, Matthew Smith wrote:
I have followed the 'recipe' at https://code.google.com/p/sipml5/wiki/Asterisk pretty well to the letter, with the exception that, since I don't have a Windows machine with audio (only a VM, no sound,) I tested with an Android SIP client (CSipSimple) instead of Xlite.

Asterisk is running on a virtual machine on my LAN - no firewalls involved.

I have established a connection to Asterisk from http://sipml5.org/asterisk/call.htm and - when calling an unconnected number, got voicemail. So OK there.

However, when I try to make a call to the connection through Chrome/SIPML5 - either from the Android SIP client or from another machine running Chrome/SIPML5 - I get a long string of errors, then Asterisk terminates.

Here is a sample of what I see from the Asterisk CLI: 

Connected to Asterisk SVN-trunk-r376131M currently running on asterisk2 (pid = 1743)
  == WebSocket connection from '10.10.10.16:45086' for protocol 'sip' accepted using version '13'
  == WebSocket connection from '10.10.10.209:37712' for protocol 'sip' accepted using version '13'
  == Using SIP RTP CoS mark 5
  == Using SIP RTP CoS mark 5
[Dec 17 08:03:38] WARNING[1889][C-00000000]: res_rtp_asterisk.c:1451 __rtp_recvfrom: PJ ICE Rx error status code: 370401 'Unauthorized'.
[Dec 17 08:03:38] WARNING[1889][C-00000000]: res_rtp_asterisk.c:1451 __rtp_recvfrom: PJ ICE Rx error status code: 370401 'Unauthorized'.
[Dec 17 08:03:38] WARNING[1889][C-00000000]: res_rtp_asterisk.c:1451 __rtp_recvfrom: PJ ICE Rx error status code: 370401 'Unauthorized'.
[Dec 17 08:03:38] WARNING[1889][C-00000000]: res_rtp_asterisk.c:1451 __rtp_recvfrom: PJ ICE Rx error status code: 370401 'Unauthorized'.
...
lots more of the above
...
[Dec 17 08:03:38] WARNING[1889][C-00000000]: res_rtp_asterisk.c:1451 __rtp_recvfrom: PJ ICE Rx error status code: 370401 'Unauthorized'.
[Dec 17 08:03:41] ERROR[1888][C-00000000]: netsock2.c:269 ast_sockaddr_resolve: getaddrinfo("df7jal23ls0d.invalid", "(null)", ...): Name or service not known
[Dec 17 08:03:41] WARNING[1888][C-00000000]: chan_sip.c:15777 __set_address_from_contact: Invalid host name in Contact: (can't resolve in DNS) : 'df7jal23ls0d.invalid'
asterisk2*CLI> 
Disconnected from Asterisk server
Executing last minute cleanups
Asterisk cleanly ending (0).

Can anyone throw any light on why this is happening and what I can try to remedy it?

Cheers

M
--
 
 

sic...@gmail.com

unread,
Jan 15, 2013, 10:44:46 AM1/15/13
to Mamadou, doub...@googlegroups.com, smiff...@gmail.com
Hi,

On Tue, Jan 15, 2013 at 4:03 PM, Mamadou <diopm...@doubango.org> wrote:
> Good that you fixed your issue but your diagnostic is not correct.
> STUN server is only used to gather public IPs and it must be on public
> network. If your STUN server is on the local network, this means the
> gathered addresses will be private.

So let me try to understand. Are you saying that if all the parties
involved (asterisk server and both sipml5 clients) are on the same
LAN my change are useless?

Because I've just tried again and without the change I've mentioned
in the prev post the caller is able to hear what the callee are saying
whereas the callee don't hear anything. After setting as STUN a local
server both parties are able to listen.

Maybe I'm missing something obvious in my setup, because If
I have to be honest initially I was quite unsure about the effectiveness
of the proposed changes, but I stand corrected once a colleague of
mine show me that they worked.

One last thing that I forgot to mention in the prev post, despite the
fact that the call is working correctly I got a lot this kind warning on
asterisk console:

[Jan 15 16:39:22] WARNING[10151][C-00000014]: res_rtp_asterisk.c:1451
__rtp_recvfrom: PJ ICE Rx error status code: 370401 'Unauthorized'.
[Jan 15 16:39:22] WARNING[10151][C-00000014]: res_rtp_asterisk.c:1451
__rtp_recvfrom: PJ ICE Rx error status code: 370401 'Unauthorized'.

those above stopped once the callee answers.

Than on on hang up I've this one, repeated only one time.

[Jan 15 16:39:22] ERROR[10140][C-00000014]: netsock2.c:269
ast_sockaddr_resolve: getaddrinfo("df7jal23ls0d.invalid", "(null)",
...): Name or service not known
[Jan 15 16:39:22] WARNING[10140][C-00000014]: chan_sip.c:15775
__set_address_from_contact: Invalid host name in Contact: (can't
resolve in DNS) : 'df7jal23ls0d.invalid'
-- SIP/1061-00000025 answered SIP/1060-00000024
== Spawn extension (default, 1061, 1) exited non-zero on 'SIP/1060-00000024'

Andrea

Mamadou

unread,
Jan 15, 2013, 11:11:42 AM1/15/13
to doub...@googlegroups.com, sic...@gmail.com, smiff...@gmail.com
Let me explained:
- Chrome use ICE to find the best IP address to use
- ICE is negotiated between two peers. And what is negotiated is
candidates.
- An ICE candidate is an IP address and port. There are 3 type of
candidates: "local", "server reflexive" and peer reflexive.
- Before sending the SIP INVITE request, a client supporting ICE
gather local and server reflexive candidates and add them to the SDP
- "Local" candidates are the local IP addresses (NIC). e.g. 192.168.0.1
- "server reflexive" are public IP addresses. As you may expect, a
client cannot know it's public IP address and here is where STUN comes.
a) the STUN server is placed on the public network
b) the client sends a STUN binding request to the server
c) the server send back a response and include the IP address and
port from which it received the request. This IP address is Public as
the server is on public network
d) the client check the response and the returned IP address and
Port to it's candidates
- The client sends the INVITE with both local and reflexive addresses.
- When the server receive the response it performs the same process and
send back 200 OK with its candidates
- Both the client and server send STUN binding requests to the other
candidates (this is named connection checking) until a pair success.
- When a candidate receives a STUN binding request for the first time it
get the remote IP address and add it as "peer reflexive" candidate to be
checked.
- When a pair succeed (we got response on both sides), it's used for
communication (RTP)

In short: using a STUN server placed on the same (sub)network as the
client is useless.
If you open a ticket and attach full network trace we could help to
understand what's the issue.

sic...@gmail.com

unread,
Jan 15, 2013, 11:19:55 AM1/15/13
to Mamadou, smiff...@gmail.com, doub...@googlegroups.com

Many thanks for the detailed explanation! I'm commuting home now, tomorrow (CET) i will try to capture the network traffic involved and I'll open a ticket with the full dump attached.

Do you have any "ready-to-use" tcpdump filter to get all the needed packets?

Andrea

Mamadou

unread,
Jan 15, 2013, 12:47:52 PM1/15/13
to sic...@gmail.com, smiff...@gmail.com, doub...@googlegroups.com
Please note that current chrome stable (24) contain a bug on ICE side as I explained at https://groups.google.com/group/doubango/browse_thread/thread/3eec5fec71dda522#.
Using local STUN server is like disabling Public IP gathering and this could explain why it works. Instead of using a local STUN server with slow down the connection process, just disable it.
If you're not an expert we recommend using webrtc2sip.

sic...@gmail.com

unread,
Jan 15, 2013, 12:54:52 PM1/15/13
to Mamadou, smiff...@gmail.com, doub...@googlegroups.com

I'm using google chrome ver 25.0.1364.29 dev (os ubuntu 12.04 64bit)

Mamadou

unread,
Jan 15, 2013, 12:56:07 PM1/15/13
to sic...@gmail.com, smiff...@gmail.com, doub...@googlegroups.com
ok...let me try with my Asterisk server

sic...@gmail.com

unread,
Jan 15, 2013, 1:03:26 PM1/15/13
to Mamadou, smiff...@gmail.com, doub...@googlegroups.com


On Jan 15, 2013 6:47 PM, "Mamadou" <diopm...@doubango.org> wrote:
>

> Please note that current chrome stable (24) contain a bug on ICE side as I explained at https://groups.google.com/group/doubango/browse_thread/thread/3eec5fec71dda522#.
> Using local STUN server is like disabling Public IP gathering and this could explain why it works. Instead of using a local STUN server with slow down the connection process, just disable it.
> If you're not an expert we recommend using webrtc2sip.
>

We definitely want to try the full stack (webrtc2sip, media coder etc)
but let's say that we're aiming to becoming experts since we want to deploy this new webrtc based tech as substitute of legacy app in our facilty

sic...@gmail.com

unread,
Jan 15, 2013, 1:04:43 PM1/15/13
to Mamadou, smiff...@gmail.com, doub...@googlegroups.com

we're using asterisk 11.2.0 properly patched

sic...@gmail.com

unread,
Jan 16, 2013, 3:36:32 AM1/16/13
to Mamadou, Matthew Smith, doub...@googlegroups.com
I'm going to try know to catch a full network trace.
I'm planning to add also the console log for both
callee and caller.

On Tue, Jan 15, 2013 at 6:56 PM, Mamadou <diopm...@doubango.org> wrote:
> ok...let me try with my Asterisk server

did you discover something ?

Andrea

sic...@gmail.com

unread,
Jan 16, 2013, 4:21:32 AM1/16/13
to Mamadou, Matthew Smith, doub...@googlegroups.com
On Tue, Jan 15, 2013 at 6:47 PM, Mamadou <diopm...@doubango.org> wrote:
> . Instead of using a local STUN server with slow down the connection
> process, just disable it.

Is there a simple way to disable the stun server ?

chyiannakou

unread,
May 4, 2015, 9:47:11 AM5/4/15
to doub...@googlegroups.com, diopm...@doubango.org, smiff...@gmail.com
Hi Mamadou,

I was facing the same issue with Andrea Suisani, i have FreePBX with Asterisk 11.17.1.
After setting up the STUN server as explained at the beginning in the PBX server my problem solved as well.

I am attaching the SIP trace file before setting up the STUN server for your review in order to advice where the problem is since from your earlier explanation you say that STUN server is useless in the local network.

Thank you

Christodoulos 
sip_trace.txt
Reply all
Reply to author
Forward
0 new messages