coturn服务器搭建

coturn服务器搭建

    • libevent下载安装
    • coturn下载安装
    • 查看是否安装成功
    • 修改配置信息
    • 启动服务
    • 遇见的问题
  • 补充

libevent下载安装

依赖libevent开源库,需要先进行安装:

wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar zxvf libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable 
./configure
make
make install

coturn下载安装

git clone https://github.com/coturn/coturn
cd coturn 
./configure 
make 
make install

查看是否安装成功

which turnserver

修改配置信息

vi /usr/local/etc/turnserver.conf

修改配置文件信息:

relay-device=eth0   #与前ifconfig查到的网卡名称一致
listening-ip=106.75.26.76   #内网IP
listening-port=3478	#默认端口号
tls-listening-port=5349
relay-ip=10.10.128.111
external-ip=10.10.128.111   #公网IP
relay-threads=50
lt-cred-mech
cert=/etc/turn_server_cert.pem
pkey=/etc/turn_server_pkey.pem
pidfile=”/var/run/turnserver.pid”
min-port=49152	     #最小端口号
max-port=65535	     #最大端口号
user=ceshi:123456    #用户名密码,创建IceServer时用

用户名密码使用如下:

List<String> urls = new ArrayList<>();
urls.add("turn:106.75.26.76:3478?transport=udp");
urls.add("turn:106.75.26.76:3478?transport=tcp");
this.iceServers.add(PeerConnection.IceServer.builder(urls).setUsername("ceshi").setPassword("123456").setTlsCertPolicy(TLS_CERT_POLICY_SECURE).createIceServer());

启动服务

turnserver -o -a -f -user=ceshi:123456 -r Beijing

遇见的问题

问题1:

[root@10-10-128-155 coturn]# ./configure
install is /usr/bin/install
pkill is /usr/bin/pkill
sqlite3 is /usr/bin/sqlite3
Use TMP dir /var/tmp
Compiler: cc
Library option -lsocket cannot be used
Library option -lwldap32 cannot be used
Library option -lwldap64 cannot be used
Library option -lintl cannot be used
Sockets code is fine: no sin_len field present
Ignore IP_RECVERR
Library option -lcrypto cannot be used
ERROR: OpenSSL Crypto development libraries are not installed properly in required location.
Abort.

解决方案:
需要依赖openssl库

yum install openssl-devel

问题2:

CONFIG ERROR: Empty cli-password, and so telnet cli interface is disabled! Please set a non empty cli-password!

解决方案:
在配置文件/usr/local/etc/turnserver.conf中,添加cli-password字段,修改后的配置文件如下:

relay-device=eth0   #与前ifconfig查到的网卡名称一致
listening-ip=106.75.26.76   #内网IP
listening-port=3478	#默认端口号
tls-listening-port=5349
relay-ip=10.10.128.111
external-ip=10.10.128.111   #公网IP
relay-threads=50
lt-cred-mech
cert=/etc/turn_server_cert.pem
pkey=/etc/turn_server_pkey.pem
pidfile=”/var/run/turnserver.pid”
min-port=49152	     #最小端口号
max-port=65535	     #最大端口号
user=ceshi:123456    #用户名密码,创建IceServer时用
cli-password=123456

补充

如果以上步骤后发现穿透服务器无法工作,可以在执行时尝试添加- v参数,打印更详细的日志,https://blog.csdn.net/Martin_chen2/article/details/102970731也记录了我部署coturn的问题,可供参考。

参考链接:
https://github.com/pchab/ProjectRTC
https://github.com/pchab/AndroidRTC
https://www.jianshu.com/p/915eab39476d

你可能感兴趣的:(webrtc,音视频)