невозможно подключиться к серверу Coturn - PullRequest
0 голосов
/ 17 мая 2019

Я следую официальным документам coturn и пытаюсь настроить сервер coturn для обработки STUN и TURN запросов.Я проверяю, работает ли мой сервер правильно, используя этот маленький JS-скрипт:

function checkTURNServer(turnConfig, timeout){ 

  return new Promise(function(resolve, reject){

    setTimeout(function(){
        if(promiseResolved) return;
        resolve(false);
        promiseResolved = true;
    }, timeout || 5000);

    var promiseResolved = false
      , myPeerConnection = window.RTCPeerConnection || window.mozRTCPeerConnection || window.webkitRTCPeerConnection   //compatibility for firefox and chrome
      , pc = new myPeerConnection({iceServers:[turnConfig]})
      , noop = function(){};
    pc.createDataChannel("");    //create a bogus data channel
    pc.createOffer(function(sdp){
      if(sdp.sdp.indexOf('typ relay') > -1){ // sometimes sdp contains the ice candidates...
        promiseResolved = true;
        resolve(true);
      }
      pc.setLocalDescription(sdp, noop, noop);
    }, noop);    // create offer and set local description
    pc.onicecandidate = function(ice){  //listen for candidate events
      if(promiseResolved || !ice || !ice.candidate || !ice.candidate.candidate || !(ice.candidate.candidate.indexOf('typ relay')>-1))  return;
      promiseResolved = true;
      resolve(true);
    };
  });   
}

и запускаю его с моими учетными данными:

checkTURNServer({"url":"turn:IP1:3478",'username': 'bayaz',"credential":"magi"}).then(function(bool){
    console.log('is TURN server active? ', bool? 'yes':'no');
}).catch(console.error.bind(console));

Где пользователь был создан с помощью;

turnadmin -A -u bayaz -p magi

Это строки без комментариев в файле конфигурации:

listening-port=3478
tls-listening-port=5349
listening-ip=IP1
listening-ip=IP2    
verbose 
lt-cred-mech
realm=mydomain.com
cert=/etc/letsencrypt/live/mydomain.com/cert.pem
pkey=/etc/letsencrypt/live/mydomain.com/privkey.pem

Это результат работы turnserver -c path/to/file.conf

0: log file opened: /var/tmp/turn_10200_2019-05-17.log
0: Listener address to use: IP1
0: Listener address to use: IP2
0: 
RFC 3489/5389/5766/5780/6062/6156 STUN/TURN Server
Version Coturn-4.5.0.8 'dan Eider'
0: 
Max number of open files/sockets allowed for this process: 4096
0: 
Due to the open files/sockets limitation,
max supported number of TURN Sessions possible is: 2000 (approximately)
0: 

==== Show him the instruments, Practical Frost: ====

0: TLS supported
0: DTLS supported
0: DTLS 1.2 supported
0: TURN/STUN ALPN supported
0: Third-party authorization (oAuth) supported
0: GCM (AEAD) supported
0: OpenSSL compile-time version: OpenSSL 1.0.2k-fips  26 Jan 2017 (0x100020bf)
0: 
0: SQLite supported, default database location is /usr/local/var/db/turndb
0: Redis is not supported
0: PostgreSQL is not supported
0: MySQL is not supported
0: MongoDB is not supported
0: 
0: Default Net Engine version: 3 (UDP thread per CPU core)

=====================================================

0: Domain name: 
0: Default realm: mydomain.com
0: SSL23: Certificate file found: /etc/letsencrypt/live/mydomain.com/cert.pem
0: SSL23: Private key file found: /etc/letsencrypt/live/mydomain.com/privkey.pem
0: TLS1.0: Certificate file found: /etc/letsencrypt/live/mydomain.com/cert.pem
0: TLS1.0: Private key file found: /etc/letsencrypt/live/mydomain.com/privkey.pem
0: TLS1.1: Certificate file found: /etc/letsencrypt/live/mydomain.com/cert.pem
0: TLS1.1: Private key file found: /etc/letsencrypt/live/mydomain.com/privkey.pem
0: TLS1.2: Certificate file found: /etc/letsencrypt/live/mydomain.com/cert.pem
0: TLS1.2: Private key file found: /etc/letsencrypt/live/mydomain.com/privkey.pem
0: TLS cipher suite: DEFAULT
0: DTLS: Certificate file found: /etc/letsencrypt/live/mydomain.com/cert.pem
0: DTLS: Private key file found: /etc/letsencrypt/live/mydomain.com/privkey.pem
0: DTLS1.2: Certificate file found: /etc/letsencrypt/live/mydomain.com/cert.pem
0: DTLS1.2: Private key file found: /etc/letsencrypt/live/mydomain.com/privkey.pem
0: DTLS cipher suite: DEFAULT
0: Relay address to use: IP1
0: Relay address to use: IP2
Cannot create pid file: /var/run/turnserver.pid: Permission denied
0: Cannot create pid file: /var/run/turnserver.pid
0: pid file created: /var/tmp/turnserver.pid
0: IO method (main listener thread): epoll (with changelist)
0: Wait for relay ports initialization...
0:   relay IP1 initialization...
0:   relay IP1 initialization done
0:   relay IP2 initialization...
0:   relay IP2 initialization done
0: Relay ports initialization done
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=1 created
0: IPv4. TLS/SCTP listener opened on : IP1:3478
0: IPv4. TLS/TCP listener opened on : IP1:3478
0: IPv4. TLS/SCTP listener opened on : IP1:3479
0: IPv4. TLS/TCP listener opened on : IP1:3479
0: IPv4. TLS/SCTP listener opened on : IP1:5349
0: IPv4. TLS/TCP listener opened on : IP1:5349
0: IPv4. TLS/SCTP listener opened on : IP1:5350
0: IPv4. TLS/TCP listener opened on : IP1:5350
0: IPv4. TLS/SCTP listener opened on : IP2:3478
0: IPv4. TLS/TCP listener opened on : IP2:3478
0: IPv4. TLS/SCTP listener opened on : IP2:3479
0: IPv4. TLS/TCP listener opened on : IP2:3479
0: IPv4. TLS/SCTP listener opened on : IP2:5349
0: IPv4. TLS/TCP listener opened on : IP2:5349
0: IPv4. TLS/SCTP listener opened on : IP2:5350
0: IPv4. TLS/TCP listener opened on : IP2:5350
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=0 created
0: IPv4. TLS/TCP listener opened on : IP1:3478
0: IPv4. TLS/TCP listener opened on : IP1:3479
0: IPv4. TLS/TCP listener opened on : IP1:5349
0: IPv4. TLS/TCP listener opened on : IP1:5350
0: IPv4. TLS/TCP listener opened on : IP2:3478
0: IPv4. TLS/TCP listener opened on : IP2:3479
0: IPv4. TLS/TCP listener opened on : IP2:5349
0: IPv4. TLS/TCP listener opened on : IP2:5350
0: IPv4. DTLS/UDP listener opened on: IP1:3478
0: IPv4. DTLS/UDP listener opened on: IP1:3479
0: IPv4. DTLS/UDP listener opened on: IP1:5349
0: IPv4. DTLS/UDP listener opened on: IP1:5350
0: IPv4. DTLS/UDP listener opened on: IP2:3478
0: IPv4. DTLS/UDP listener opened on: IP2:3479
0: IPv4. DTLS/UDP listener opened on: IP2:5349
0: IPv4. DTLS/UDP listener opened on: IP2:5350
0: Total General servers: 2
0: IO method (admin thread): epoll (with changelist)
0: IO method (auth thread): epoll (with changelist)
0: IO method (auth thread): epoll (with changelist)
0: IPv4. CLI listener opened on : 127.0.0.1:5766
0: SQLite DB connection success: /usr/local/var/db/turndb

Когда я тестирую свой сервер поворотов, я получаюмое пользовательское сообщение об ошибке "is TURN server active? no" в консоли, которое указывало, что я не получил ответа от сервера.

Я уже потратил несколько дней, пытаясь выяснить это, но мне не повезло.Что мне здесь не хватает?

1 Ответ

0 голосов
/ 19 мая 2019
sudo systemctl start coturn

- это ЛЕГКИЙ способ сделать вещи ... наверняка вы можете использовать команду turnserver, но подходящая команда для вас не так просто сделать.С помощью этой команды вы можете запустить сервер turn.conf, не сталкиваясь с другой проблемой .... это мой конфиг Приложение webrtc показывает, что мой сервер Turn не работает, но он работает ... Я использую его с локальным сервером DNSсервер apache2 с редиректом и прокси, весь трафик UDP весь на 443 порту (не для явного поворота).Котурн 4,5.Обратите внимание на no-cli и все параметры cli ... если я использую только параметр no-cli, сервер не запускается.Читайте мой ответ тоже.

...