1
votes

I have actually followed this WebRTC codelab (https://codelabs.developers.google.com/codelabs/webrtc-web/#7), but get stuck when needing to connect to ICE servers.

Essential code here:

main.js

var pcConfig = {
  'iceServers': [{
    'url': 'stun:stun.l.google.com:19302'
}

[...]

if (location.hostname !== 'localhost') {
 requestTurn(
   'https://computeengineondemand.appspot.com/turn?username=41784574&key=4080218913');}

Usually I get either error: “ICE failed”, or “Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://computeengineondemand.appspot.com/turn?username=41784574&key=4080218913. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).”

According to the latter one, I have enabled “A2enmod headers” and set this to apache.conf “Header always set Access-Control-Allow-Origin "*" “

The issue persists. My STUN server is “ 'url': 'stun:stun.l.google.com:19302' “ As far as I have understood, STUN should work 80% of the time. But this never works. Therefore, even if the TURNserver would not be working anymore, it should connect sometimes with the STUN?

1
the same concerned with me ! Can I add your telegram\skype to disscuss this solution?Loint
I have not found a solution to this but you are welcome to mail me [email protected]Gideons
So I finally figured out that the network in my office was blocking everything - STUN servers failed always. I set up an own TURN server and ta-daa - video calls finally workGideons
Made some useful tests wih this demo.easyrtc.com/demos/demo_ice_filter.htmlGideons

1 Answers

2
votes

STUN should work 80% of the time means that for 80% of Internet end users, STUN should work some (most) of the time. Whether you are in this 80% depends on network configuration, most notably whether UDP is allowed.

You can check the STUN traffic yourself using a tool like Wireshark, or tcpdump.

ICE uses both STUN and TURN. If neither STUN nor TURN work, you will not be able to connect WebRTC peer connections to endpoints outside your own network.

You also need to add the TURN server to your iceServers.