webrtc(2):Centos6 安装 stun/turn服务

本文涉及的产品
云数据库 Redis 版,社区版 2GB
推荐场景:
搭建游戏排行榜
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: 本文的原文连接是: http://blog.csdn.net/freewebsys/article/details/47109183 未经博主允许不得转载。1,关于stun和turnSTUN(Simple Traversal of UDP over NATs,NAT 的UDP简单穿越)是一种网络协议,它允许位于NAT(或多重NAT)后的客户端找出自己的公网地址,查出自

本文的原文连接是: http://blog.csdn.net/freewebsys/article/details/47109183 未经博主允许不得转载。

1,关于stun和turn

STUN(Simple Traversal of UDP over NATs,NAT 的UDP简单穿越)是一种网络协议,它允许位于NAT(或多重NAT)后的客户端找出自己的公网地址,查出自己位于哪种类型的NAT之后以及NAT为某一 个本地端口所绑定的Internet端端口。这些信息被用来在两个同时处于NAT 路由器之后的主机之间建立UDP通信。该协议由RFC 3489定义。目前RFC 3489协议已被RFC 5389协议所取代,新的协议中,将STUN定义为一个协助穿越NAT的工具,并不独立提供穿越的解决方案。它还有升级版本RFC 7350,目前正在完善中。
http://baike.baidu.com/view/884586.htm

TURN的全称为Traversal Using Relay NAT,即通过Relay方式穿越NAT,TURN应用模型通过分配TURNServer的地址和端口作为客户端对外的接受地址和端口,即私网用户发出的报文都要经过TURNServer进行Relay转发。
http://baike.baidu.com/subview/351571/10359693.htm

2,安装

参考:
http://www.hankcs.com/program/network/compile-rfc5766-turn-server-to-build-turn-server.html

代码下载:
https://github.com/coturn/rfc5766-turn-server/releases
下载最新的tar.gz包。rfc5766-turn-server-3.2.5.9.tar.gz

安装依赖环境

##ssl 需要yum安装
yum install openssl openssl-libs libevent libevent-devel

如果还是报错,就手动安装libevent。

centos Libevent2 development libraries are not installed properly in required location

下载:http://libevent.org/ 官网,下载
https://sourceforge.net/projects/levent/files/libevent/libevent-2.0/libevent-2.0.22-stable.tar.gz
然后解压缩编译安装即可

编译turn-server

tar -zxvf rfc5766-turn-server-3.2.5.9.tar.gz
cd rfc5766-turn-server-3.2.5.9
./configure 
make
make install

configure成功:

more is /usr/bin/more
install is /usr/bin/install
pkill is /usr/bin/pkill
Use TMP dir /var/tmp
Compiler: cc
Do not use -lsocket
Do not use -lwldap32
Do not use -lwldap64
Do not use -lintl
Sockets code is fine: no sin_len field present
Ignore IP_RECVERR
Crypto SSL lib found.
SSL lib found.
Libevent2 development found.
Libevent2 runtime found.
Libevent2 openssl found.
Libevent2 pthreads found.

POSTGRESQL DEVELOPMENT LIBRARY (libpq.a) AND/OR HEADER (libpq-fe.h)
        ARE NOT INSTALLED PROPERLY ON THIS SYSTEM.
        THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT POSTGRESQL DATABASE SUPPORT.


MYSQL DEVELOPMENT LIBRARY (libmysqlclient) AND/OR HEADER (mysql.h)
        ARE NOT INSTALLED PROPERLY ON THIS SYSTEM.
        THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT MYSQL DATABASE SUPPORT.


HIREDIS DEVELOPMENT LIBRARY (libhiredis.*) AND/OR HEADERS (hiredis/*.h)
        ARE NOT INSTALLED PROPERLY ON THIS SYSTEM.
        THAT'S OK BUT THE TURN SERVER IS BUILDING WITHOUT REDIS SUPPORT.

PREFIX=/usr/local OSLIBS= -L/usr/local/lib/ -L/usr/local/lib/ -L/usr/local/lib64/ -L/usr/local/lib64/ -lrt -pthread -lcrypto -lssl -levent_core -levent_openssl -levent_pthreads  -Wl,-rpath,/usr/local/lib/ -Wl,-rpath,/usr/local/lib/ -Wl,-rpath,/usr/local/lib64/ -Wl,-rpath,/usr/local/lib64/ -Wl,-rpath,/usr/lib64/mysql -Wl,-rpath,/usr/local/lib DBLIBS= OSCFLAGS=-g  -Wall -Wno-deprecated-declarations -Wextra -Wformat-security -Wnested-externs -Wstrict-prototypes  -Wmissing-prototypes -Wpointer-arith -Wcast-qual -I/usr/local/include -I/usr/local/include/ -I/usr/local/include  -DTURN_HAS_DAEMON    -DINSTALL_PREFIX=/usr/local DBCFLAGS=

只是说没有数据库支持的库,暂时不需要。

安装之后说明:

1) If you system supports automatic start-up system daemon services, 
the, to enable the turnserver as an automatically started system 
service, 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, if using the turnserver 
        with authentication: create and edit /etc/turnuserdb.conf 
        file, or set up PostgreSQL or MySQL or Redis database for user accounts.
        Use /usr/local/etc/turnuserdb.conf.default as example for flat file DB,
        or 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.

        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

在根目录创建一个user.db文件
使用turnserver启动:

turnserver --userdb /root/turnuser.db 
里面是webrtc用户名密码:
webrtc:secret

3,页面调用

https://github.com/EricssonResearch/openwebrtc-examples/tree/master/web
安装node参考之前文章:
http://blog.csdn.net/freewebsys/article/details/46649667#t1

修改main.js

// must use 'url' here since Firefox doesn't understand 'urls'
var configuration = {
  "iceServers": [
  {
    "url": "stun:mmt-stun.verkstad.net"
  },
  {
    "url": "turn:mmt-turn.verkstad.net",
    "username": "webrtc",
    "credential": "secret"
  }
  ]
};

将stun服务器和turn服务器替换。

4,总结

本文的原文连接是: http://blog.csdn.net/freewebsys/article/details/47109183 未经博主允许不得转载。

stun和trun是webrtc打通的关键服务器,但是资源有限没有在公网测试。

相关实践学习
基于Redis实现在线游戏积分排行榜
本场景将介绍如何基于Redis数据库实现在线游戏中的游戏玩家积分排行榜功能。
云数据库 Redis 版使用教程
云数据库Redis版是兼容Redis协议标准的、提供持久化的内存数据库服务,基于高可靠双机热备架构及可无缝扩展的集群架构,满足高读写性能场景及容量需弹性变配的业务需求。 产品详情:https://www.aliyun.com/product/kvstore     ------------------------------------------------------------------------- 阿里云数据库体验:数据库上云实战 开发者云会免费提供一台带自建MySQL的源数据库 ECS 实例和一台目标数据库 RDS实例。跟着指引,您可以一步步实现将ECS自建数据库迁移到目标数据库RDS。 点击下方链接,领取免费ECS&RDS资源,30分钟完成数据库上云实战!https://developer.aliyun.com/adc/scenario/51eefbd1894e42f6bb9acacadd3f9121?spm=a2c6h.13788135.J_3257954370.9.4ba85f24utseFl
目录
相关文章
|
1天前
|
Linux
centos 6.5安装yum
centos 6.5安装yum
6 0
|
1天前
|
运维 网络协议 Linux
【运维系列】Centos7安装并配置PXE服务
PXE是Intel开发的预启动执行环境,允许工作站通过网络从远程服务器启动操作系统。它依赖DHCP分配IP,DNS服务分配主机名,TFTP提供引导程序,HTTP/FTP/NFS提供安装源。要部署PXE服务器,需关闭selinux和防火墙,安装dhcpd、httpd、tftp、xinetd及相关服务,配置引导文件和Centos7安装源。最后,通过syslinux安装引导文件,并创建pxelinux.cfg/default配置文件来定义启动参数。
5 0
|
1天前
|
运维 网络协议 Linux
【运维系列】Centos7安装并配置postfix服务
安装CentOS7的Postfix和Dovecot,配置Postfix的`main.cf`文件,包括修改完全域名、允许所有IP、启用邮箱等。然后,配置Dovecot的多个配置文件以启用auth服务和调整相关设置。重启Postfix和Dovecot,设置开机自启,并关闭防火墙进行测试。最后,创建邮箱账户并在Windows邮箱客户端中添加账户设置。
8 0
|
1天前
|
Linux 网络安全
Centos6.5安装并配置NFS服务
该内容描述了在Linux系统中设置NFS服务的步骤。首先挂载yum源,然后安装NFS服务,并编辑配置文件。接着,重启rpcbind和NFS服务,可能需要重复此过程以解决初始可能出现的问题。此外,关闭防火墙策略,并再次重启服务。最终,根目录被共享,特定IP网段被允许访问。
6 0
|
2天前
|
存储 Linux 网络安全
centos7使用yum网络安装
这些是使用Yum进行网络安装的基本步骤。根据你的需求,你可以重复步骤3和4来安装其他软件包。请注意,执行Yum操作需要root或具有sudo权限的用户。
14 1
|
8天前
|
关系型数据库 MySQL Linux
centos7安装mysql-带网盘安装包
centos7安装mysql-带网盘安装包
52 2
|
14天前
|
存储 Linux Shell
centos 部署docker容器 安装 、基本使用方法(一)
centos 部署docker容器 安装 、基本使用方法(一)
26 0
|
15天前
|
分布式计算 Hadoop Java
centos 部署Hadoop-3.0-高性能集群(一)安装
centos 部署Hadoop-3.0-高性能集群(一)安装
16 0
|
15天前
|
关系型数据库 MySQL Linux
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
CentOS 7 下使用yum安装MySQL5.7.20 最简单 图文详解
68 0
|
1月前
|
Linux 网络安全 数据安全/隐私保护
如何在 VM 虚拟机中安装 CentOS Linux 9 操作系统保姆级教程(附链接)
如何在 VM 虚拟机中安装 CentOS Linux 9 操作系统保姆级教程(附链接)
161 0