ubuntu 中的 TURN 服务器不工作

Posted

技术标签:

【中文标题】ubuntu 中的 TURN 服务器不工作【英文标题】:TURN server in ubuntu is not working 【发布时间】:2016-09-13 05:43:16 【问题描述】:

对于视频通话,我使用的是 Phonertc(基于 Webrtc)

我在 Ubuntu 14.04.3 LTS 中设置了 turnserver 我按照https://github.com/coturn/rfc5766-turn-server/的指示进行操作

我下载了 turnserver-3.2.5.9-debian-wheezy-ubuntu-mint-x86-64bits.tar.gz 来自http://turnserver.open-sys.org/downloads/v3.2.5.9/ 并根据提供的说明进行设置。

安装后我更改 /etc/turnserver.conf 并取消注释以下行:

fignerprint
lt-cred-mech
realm (i set my domain name)

关于 etc/turnuserdb.conf 我添加了普通的用户名和密码

当我使用命令 'turnserver' 运行 turnserver 时,它会将日志打印为

0: log file opened: /var/tmp/turn_14007_2016-05-17.log
0: 
RFC 3489/5389/5766/5780/6062/6156 STUN/TURN Server
Version Citrix-3.2.5.9 'Marshal West'
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: Redis supported
0: PostgreSQL supported
0: mysql supported
0: OpenSSL compile-time version 0x1000105f: fresh enough
0: Default Net Engine version: 2 (UDP thread per network endpoint)

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

0: Config file found: /etc/turnserver.conf
0: Config file found: /etc/turnserver.conf
0: Config file found: /etc/turnuserdb.conf
0: WARNING: cannot find certificate file: turn_server_cert.pem (1)
0: WARNING: cannot start TLS and DTLS listeners because certificate file is not set properly
0: WARNING: cannot find private key file: turn_server_pkey.pem (1)
0: WARNING: cannot start TLS and DTLS listeners because private key file is not set properly
0: NO EXPLICIT LISTENER ADDRESS(ES) ARE CONFIGURED
0: ===========Discovering listener addresses: =========
0: Listener address to use: 127.0.0.1
0: Listener address to use: 10.240.0.2
0: =====================================================
0: Total: 1 'real' addresses discovered
0: =====================================================
0: NO EXPLICIT RELAY ADDRESS(ES) ARE CONFIGURED
0: ===========Discovering relay addresses: =============
0: Relay address to use: 10.240.0.2
0: =====================================================
0: Total: 1 relay addresses discovered
0: =====================================================
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 10.240.0.2 initialization...
0:   relay 10.240.0.2 initialization done
0: Relay ports initialization done
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=0 created
0: Total UDP servers: 1
0: Total General servers: 1
0: IO method (cli thread): epoll (with changelist)
0: IO method (auth thread): epoll (with changelist)

我已经在客户端设置了ice服务器

iceServers: [
       
         url: 'stun:stun.l.google.com:19302'

        ,
        
          url: self.config.turn.host,
          username: self.config.turn.username,
          password: self.config.turn.password
        ]

在这里,当用户从移动设备呼叫时,网络用户应该从移动设备看到视频。它在wifi网络上运行良好 现在的问题是当我尝试从 3g 网络或 4g 网络呼叫时将建立但没有数据传输(视频)。屏幕变黑。

我还尝试检查不同的链接以检查我的转向服务器是否正在运行。 Easy way to test TURN server 它说turnserver没有运行。

如果我的转向服务器真的没有运行或者在眩晕和转向之间切换不起作用,我会感到困惑。

【问题讨论】:

我可能已经穿坏了,但我认为您将用户名/密码设置在错误的位置 请你建议我应该在哪里添加它。根据他们的指示,我发现我应该在 etc/turnuserdb.conf 中添加平面用户名和密码 "sudo turnserver -a -o -v -n --no-dtls --no-tls -u test:test -r "someRealm" 这是我能想到的最小的运行命令TURN 服务器\ 我试过了,但是在 3G 和 4G 网络下还是不行。你知道为什么 3g 和 4g 数据传输不起作用 我在公共 IP 中配置了 TURN 服务器,现在它工作正常。 【参考方案1】:

我遇到了问题,因为我的 turnserver 没有在公共 IP 中运行。我在一个具有公共 IP 的实例中安装了 turnserver,并通过其他网络访问它,现在它工作正常。

【讨论】:

你能分享你用来运行turnserver的命令吗?谢谢 运行 turnserver 的命令是什么意思?您使用的是哪个操作系统?根据安装指南安装 turnserver 和设置凭据。如果您在执行此操作时发现任何错误,请将错误日志粘贴到此处。 如果您已经设置了 trunserver 并想从终端运行,您可以使用命令进行测试:sudo turnserver -a -o -v -n --no-dtls --no-tls -u yourUsername: yourPassword -r "yourRealm"【参考方案2】:

我认为问题可能出在 url 配置上。而不是“url”,您应该使用“urls”。

iceServers: [
   
     urls: 'stun:stun.l.google.com:19302'

    ,
    
      urls: self.config.turn.host,
      username: self.config.turn.username,
      password: self.config.turn.password
    ]

'url' 已被弃用。更多信息请看这里:https://developer.mozilla.org/en-US/docs/Web/API/RTCIceServer/urls

【讨论】:

这不是我的解决方案。我按照@mido 的建议在公共 IP 中配置了 TURN 服务器,现在它工作正常。

以上是关于ubuntu 中的 TURN 服务器不工作的主要内容,如果未能解决你的问题,请参考以下文章

C# 中的 WebRTC STUN 和 TURN 服务器

Webrtc、websockets、Stun/turn 服务器,一起工作?

webrtc连接方法——TURN服务器和STUN服务器作用简介

WebRTC - 我需要指定多少 STUN/TURN 服务器?

NAT Traversal 仅使用 C# 中的免费 STUN 和 TURN 服务器

STUN/TURN 服务器连接测试