1. 程式人生 > >webrtc coturn伺服器搭建

webrtc coturn伺服器搭建

WebRTC 需要一個 turn服務來中轉視訊流,或者提供NAT打洞服務,Google的coturn就提供了這兩個功能,如下是下載、安裝、配置的流水賬記錄。


[[email protected] coturn]$ git clone https://github.com/coturn/coturn.git
Initialized empty Git repository in /home/work/coturn/coturn/.git/
remote: Counting objects: 6327, done.
remote: Compressing objects: 100% (24/24), done.
remote: Total 6327 (delta 7), reused 0 (delta 0), pack-reused 6303
Receiving objects: 100% (6327/6327), 2.00 MiB | 779 KiB/s, done.
Resolving deltas: 100% (4919/4919), done.
[

[email protected] coturn]$ ls
coturn
[[email protected] coturn]$ ./configure --prefix=/home/work/turn-server
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
Crypto SSL lib found.
SSL lib found.
Libevent2 development is not installed properly
ERROR: Libevent2 development libraries are not installed properly in required location.
ERROR: may be you have just too old libevent tool - then you have to upgrade it.
See the INSTALL file.
Abort.
[
[email protected]
coturn]$ sudo yum install libevent
[[email protected] coturn]$ wget https://sourceforge.net/projects/levent/files/release-2.0.22-stable/libevent-2.0.22-stable.tar.gz/download
[[email protected] coturn]$ mv download libevent-2.0.22-stable.tar.gz
[[email protected] coturn]$ tar -zxf llibevent-2.0.22-stable.tar.gz
[
[email protected]
coturn]$ cd llibevent-2.0.22-stable
[[email protected] libevent-2.0.22-stable]$./configure
[[email protected] libevent-2.0.22-stable]$make
[[email protected] libevent-2.0.22-stable]$ sudo make install
[[email protected] coturn]$ ./configure --prefix=/home/work/turn-server
[[email protected] coturn]$ make
[[email protected] coturn]$ make install
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: 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
[[email protected] bin]$ ./turnadmin -k -u test123 -r test123.com -p test123
0xxxxxxxxxxxxxxxxxx


turnserver.conf

#私有ip
listening-ip=11.11.11.11
# listening-port=3478
# tls-listening-port=5349
# relay-ip=22.22.22.22
#外網ip
external-ip=22.22.22.22
# relay-threads=50
#no-auth=true
lt-cred-mech
realm=test123.com
# username:passwd (no Ox)
user=test123:xxxxx
# userdb=/home/work/turn-server/etc/turnuserdb.conf
# max-bps=102400
pidfile=/home/work/turn-server/logs/turnserver.pid
log-file=/home/work/turn-server/logs/turn.log



[[email protected] bin]$ ./turnserver -c /home/work/turn-server/etc/turnserver.conf -o -a -f -r test123.com


強制走 turn 服務
http://stackoverflow.com/questions/22130311/webrtc-how-to-set-always-to-use-turn-server


turnserver conf詳解
http://blog.csdn.net/xyblog/article/details/49835805


官方wiki

https://github.com/coturn/coturn/wiki/turnserver


rp rb sp sb的解釋
https://github.com/coturn/coturn/blob/master/src/apps/relay/turn_admin_server.c