WebRTC和coturn安装

目前国内免费可用的stun服务器(2020.07.14 端口:3478) 

 

stun.xten.com   
stun.voipbuster.com  
stun.sipgate.net  
stun.ekiga.net
stun.ideasip.com
stun.schlund.de
stun.voiparound.com
stun.voipbuster.com
stun.voipstunt.com
stun.counterpath.com
stun.1und1.de
stun.gmx.net
stun.callwithus.com
stun.counterpath.net
stun.internetcalls.com
numb.viagenie.ca 

参考地址:WebRTC TURN协议初识及turnserver实践 https://zhuanlan.zhihu.com/p/71025431

官网地址:https://github.com/coturn/coturn

Centos7 安装coturn部署一套 STUN/TURN 服务 webRTC打洞服务器 

1、安装相关依赖

yum install -y make gcc cc gcc-c++ wget openssl-devel libevent libevent-devel

2、下载可以编译的源码包
官方下载地址:Downloads · coturn/coturn Wiki · GitHub
这里我们下载最新的4.5.0.8

wget https://coturn.net/turnserver/v4.5.0.8/turnserver-4.5.0.8.tar.gz

解压并进入目录

tar -zxvf turnserver-4.5.0.8.tar.gz
cd turnserver-4.5.0.8/

3、编译安装

./configure --prefix=/usr/local/turnserver  # 指定安装的目录
make && make install

安装完成后打印内容:

cp -rpf include/turn/client /usr/local/turnserver/include/turn
install include/turn/ns_turn_defs.h /usr/local/turnserver/include/turn
cat /usr/local/turnserver/share/doc/turnserver/postinstall.txt
==================================================================

1) If your system supports automatic start-up system daemon services, 
then to enable the turnserver as a system service that is automatically
started, you have to:

	a) Create and edit /etc/turnserver.conf or 
	/usr/local/etc/turnserver.conf . 
	Use /usr/local/etc/turnserver.conf.default as an example.

	b) For user accounts settings: set up SQLite or PostgreSQL or 
	MySQL or MongoDB or Redis database for user accounts.
	Use /usr/local/share/turnserver/schema.sql as SQL database schema,
	or use /usr/local/share/turnserver/schema.userdb.redis as Redis
	database schema description and/or 
	/usr/local/share/turnserver/schema.stats.redis
	as Redis status & statistics database schema description.
	
	If you are using SQLite, the default database location is in 
	/var/db/turndb or in /usr/local/var/db/turndb or in /var/lib/turn/turndb.
	 
	c) add whatever is necessary to enable start-up daemon for the 
	/usr/local/bin/turnserver.
     
2) If you do not want the turnserver to be a system service, 
   then you can start/stop it "manually", using the "turnserver" 
   executable with appropriate options (see the documentation).
   
3) To create database schema, use schema in file 
/usr/local/share/turnserver/schema.sql.
   
4) For additional information, run:
 
   $ man turnserver
   $ man turnadmin
   $ man turnutils
	
==================================================================

4、设置环境变量
编辑root目录下.bashrc文件 vi ~/.bashrc
插入一下内容

export turnserver_home=/usr/local/turnserver
export PATH=$PATH:$turnserver_home/bin

5、编辑配置文件
先找到配置文件位置

find /usr -name turnserver.conf
#编辑配置文件
vim /usr/local/turnserver/share/examples/turnserver/etc/turnserver.conf

在配置文件末尾加入一下内容

listening-port=3478  # 监听的端口
### listening-ip=x.x.x.x  # 监听的内网IP
external-ip=x.x.x.x # 监听的外网IP (如果在云主机)指定云主机的公网IP地址
user=user:123456  # 设置账号密码

6、指定配置文件启动服务
turnserver -v -r 外网ip -a -o -c /usr/local/turnserver/share/examples/turnserver/etc/turnserver.conf

注意:如果使用的是阿里云或腾讯云的服务器,要开发对应端口的访问,关闭对应端口的防火墙

测试是否配置成功

https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/

在这里插入图片描述

 ————————————————
版权声明:本文为CSDN博主「haeasringnar」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/haeasringnar/article/details/94607464

验证失败

0: Domain name: 
0: Default realm: xxxxxxxxx
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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值