设置NodeJs WebRTCvideo通话,Turn / ICE失败,CORS被阻塞

我实际上已经遵循这个WebRTC codelab( https://codelabs.developers.google.com/codelabs/webrtc-web/#7 ),但是当需要连接到ICE服务器时卡住了。

基本代码在这里:

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');} 

通常,我得到以下错误:“ICE失败”或“跨源请求被阻止:同源策略不允许通过https://computeengineondemand.appspot.com/turn?username=41784574&key=4080218913阅读远程资源。 (原因:缺lessCORS头'Access-Control-Allow-Origin')。“

根据后者,我已经启用了“A2enmod标题”,并将其设置为apache.conf“标题始终设置Access-Control-Allow-Origin”*“”

问题依然存在。 我的STUN服务器是“'url':'stun:stun.l.google.com:19302'”据我所知,STUN应该工作80%的时间。 但是这从来没有工作。 因此,即使TURN服务器不再工作,它应该有时与STUN连接?

STUN应该工作80%的时间意味着对于80%的互联网terminal用户,STUN应该工作一些(大部分时间)。 无论你在这80%是否依赖networkingconfiguration,最显着的是UDP是否被允许。

您可以使用Wireshark或tcpdump等工具自行检查STUNstream量。

ICE同时使用STUN和TURN。 如果STUN和TURN都不起作用,您将无法将WebRTC对等连接连接到您自己networking之外的端点。

您还需要将TURN服务器添加到您的iceServers