Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/asp.net-mvc-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
webRTC';s使用专用和公用IP地址(如Stackpath或AWS EC2)进行设置?_Webrtc_Coturn - Fatal编程技术网

webRTC';s使用专用和公用IP地址(如Stackpath或AWS EC2)进行设置?

webRTC';s使用专用和公用IP地址(如Stackpath或AWS EC2)进行设置?,webrtc,coturn,Webrtc,Coturn,我花了很多时间试图使Coturn在同时具有Public(Public_ID_ADDRESS)和Private(Private_ID_ADDRESS)IP地址的vm上工作。下面的工作,可能有人会发现它的帮助。 当然,用IP地址替换公共ID地址和私有ID地址 1) 我通过在/www/js/main.js中添加iceTransportPolicy:“relay”来阻止点对点测试回合服务器,请参见下文 2) 我使用443而不是默认的3478端口,用于使用自定义TURN coturn服务器的TURN通信

我花了很多时间试图使Coturn在同时具有Public(Public_ID_ADDRESS)和Private(Private_ID_ADDRESS)IP地址的vm上工作。下面的工作,可能有人会发现它的帮助。 当然,用IP地址替换公共ID地址和私有ID地址

1) 我通过在/www/js/main.js中添加
iceTransportPolicy:“relay”
来阻止点对点测试回合服务器,请参见下文 2) 我使用443而不是默认的3478端口,用于使用自定义TURN coturn服务器的TURN通信 3) $sudo ufw status下方仅显示打开的端口

   22/tcp                     ALLOW       Anywhere
   80/tcp                     ALLOW       Anywhere
   443/tcp                    ALLOW       Anywhere
   443/udp                    ALLOW       Anywhere
   22/tcp (v6)                ALLOW       Anywhere (v6)
   80/tcp (v6)                ALLOW       Anywhere (v6)
   443/tcp (v6)               ALLOW       Anywhere (v6)
   443/udp (v6)               ALLOW       Anywhere (v6)
文件:
/etc/hosts

   127.0.0.1       localhost
   127.0.1.1    mycoturn.com
   PRIVATE_ID_ADDRESS mycoturn.com

    # The following lines are desirable for IPv6 capable hosts
    ::1     localhost ip6-localhost ip6-loopback
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
确保TURN服务器具有正确的主机名:
$sudo hostnamectl set hostname mycoturn.com

文件:/etc/turnserver.conf

listening-port=443
tls-listening-port=443
listening-ip=PRIVATE_ID_ADDRESS
relay-ip=PRIVATE_ID_ADDRESS
external-ip=PUBLIC_ID_ADDRESS
min-port=10000
max-port=20000
verbose
fingerprint
lt-cred-mech
server-name=mycoturn.com
user=turn-user:turn-password
realm=mycoturn.com
cert=/etc/letsencrypt/live/mycoturn.com/fullchain.pem
pkey=/etc/letsencrypt/live/mycoturn.com/privkey.pem
log-file=/var/log/turnserver.log
也在客户端静态网页上 文件:staticHTML/www/js/config.js

 const stunUrl = 'stun:stun.l.google.com:19302',
 turnUrl = 'turn:mycoturn.com:443',
 turnUsername = 'turn-user',
 turnPassword = 'turn-password',
 timeLimit = 10, // in minutes
 appName = "myawesomeapp.com"; 

  var signalingURL = "";

  if (location.hostname === "localhost" || location.hostname === "127.0.0.1") {
    signalingURL = 'http://localhost:9000';
  } else {
    signalingURL = 'https://signaling.mycoturn.com';
  }
 
文件:staticHTML/www/js/main.js

 $(document).ready(function() {
 const socket = io.connect(signalingURL), userInfo = {
     userName: '', room: '',
 }, localVideo = document.getElementById('localVideo'), remoteVideo = 
   document.getElementById('remoteVideo'),
     configuration = {
        'iceServers': [
            { 'url': stunUrl },
            {
                'urls': turnUrl,
                'username': turnUsername,
                'credential': turnPassword
            }
        ],
           iceTransportPolicy: "relay"  // added to test the turn server and block peer to peer p2p.
       },
       isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent),
       urlParams = new URLSearchParams(window.location.search);  ...