随笔 - 632  文章 - 17  评论 - 54  阅读 - 93万

CentOS7.3 coturn服务搭建

一、概述

  本次环境搭建是在阿里云CentOS7.3上进行搭建的。主要任务是为WebRTC的NAT穿越提供服务,使通讯双方可以进行有效的网络协商

二、搭建步骤

  1.安装openssl和openssl-devel  

1
2
yum install openssl
yum -y install openssl-devel

  2.下载并安装libevent

1
2
3
4
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

  3.下载coturn并编译安装

1
2
3
4
5
git clone https://github.com/coturn/coturn
cd coturn
./configure --prefix=/usr/local/coturn
make -j 4
make install

  4.配置coturn

1
2
cd /usr/local/coturn/etc/
cp turnserver.conf.default turnserver.conf

  5.查看网卡,记录网卡名称、内网地址并到阿里云查看自己的外网ip

  使用以下命令查看网卡名称和内网地址:  

1
ifconfig -a

 以下是输出:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.26.37.146  netmask 255.255.192.0  broadcast 172.26.63.255
        ether 00:16:3f:00:2f:d7  txqueuelen 1000  (Ethernet)
        RX packets 5691670  bytes 1161400745 (1.0 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 4216357  bytes 2264619937 (2.1 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
 
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1  (Local Loopback)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

  6.修改配置信息:

1
vim /usr/local/coturn/etc/turnserver.conf

  赋值下面这段到turnserver.conf,并更改响应的自定义项

1
2
3
4
5
6
7
8
9
10
11
12
cli-password=设置一个密码
relay-device=eth0
listening-ip=内网ip地址
listening-port=3478
tls-listening-port=5349
external-ip=外网ip地址
relay-ip=内网ip地址
relay-threads=50
lt-cred-mech
cert=/csr/35manstudy.top.pem       //https的key和pem
pkey=/csr/35manstudy.top.key        //https的key和pem
user=用户名

  7.运行一下命令开启turn服务

1
turnserver -o -a -f -user=密码 -r 用户名

  运行后只要控制台不报错基本上就成功了。

  8.运行一下网址,如果出现以下截图则说明配置成功

1
http://你自己的公网ip:3478/

  

 

 

 

   ps:由于我这台服务器是阿里云的,所有使用到的端口都必须再阿里云后台配置,不然端口不会生效。如下图所示:

 

   上面的步骤一通操作只要流程正常走下来基本都能通过。而且我也对coturn做了Androi端的网络协商、媒体协商测试。都没啥问题,都可以显示多人画面。后续会贴出响应的代码以供参考

posted on   飘杨......  阅读(595)  评论(0编辑  收藏  举报
编辑推荐:
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示