简介
     apprtc 是什么,webrtc.org官方指定体验app
 
 
原料:
ubuntu14.04,其他linux版本不限,官方并没特殊说明
chrome M51+
 
 
 
步骤:
 
设置代理
由于国内网络的特殊性,这步非常关键,如果没有靠谱的代理,很可能以失败告终。
设置shell环境的代理
添加如下内容到 ~/.bashrc
export http_proxy=http://10.xx.xx.xx:100
export https_proxy=http://10.xx.xx.xx:100
     
设置git的代理
添加如下内容到  ~/.gitconfig
[http]
         proxy = http://10.xx.xx.xx:100
         sslverify = false
[https]
          proxy = http://10.xx.xx.xx:100
 
 
下载,解压.
建议存放在和apprtc同级目录
 
├── code
│   ├── google_appengine
│   ├── apprtc
 
 
安装apprtc
下载apprtc源码
建议存放在和google_appengine同级目录
 
├── code
│   ├── google_appengine
│   ├── apprtc
 
 
 
安装npm
下面摘录自[1],如果设置好代理之后,这些步骤可很顺利的完成
 
Install grunt by first installing npm. npm is distributed as part of nodejs.
sudo apt-get install nodejs

sudo npm install -g npm
 
On Ubuntu 14.04 the default packages installs /usr/bin/nodejs but the /usr/bin/node executable is required for grunt. This is installed on some Ubuntu package sets; if it is missing, you can add this by installing the nodejs-legacypackage,
sudo apt-get install nodejs-legacy
 
It is easiest to install a shared version of grunt-cli from npm using the -g flag. This will allow you access the gruntcommand from /usr/local/bin. More information can be found on gruntjs Getting Started.
sudo npm -g install grunt-cli

Omitting the -g flag will install grunt-cli to the current directory under the node_modules directory.

 
Finally, you will want to install grunt and required grunt dependencies. This can be done from any directory under your checkout of the webrtc/apprtc repository.
npm install

On Ubuntu, you will also need to install the webtest package:

sudo apt-get install python-webtest
 
编译apprtc
sudo grunt build --force
每次更新修改代码都应该重新编译,编译生成的文件存放在out目录中
 
 
运行apprtc
sudo ../google_appengine//dev_appserver.py ./out/app_engine --host 0.0.0.0
 
 
安装 rfc5766-turn-server 
sudo app-get install rfc5766-turn-server
配置
编辑 /etc/trunserver.conf
确保打开了以下行的注释,并且赋予正确的值,port,ip的值当然要按照实际情况填写,static-auth-secret=4080218913最好也不要修改成其他值,因为apprtc硬编码了这个值,除非你也去修改apprtc里对应的地方。realm=cn.cn 这个没有要求,填写自己的域名即可。Verbose 不是必须的,打开它只是为了可以看到更多输出而已。
 
18:listening-port=9000
52:listening-ip=10.58.60.236
97:relay-ip=10.58.60.236
154:Verbose
203:use-auth-secret
211:static-auth-secret=4080218913
289:realm=cn.cn
446:
 
 
制作证书
➜  apprtc git:(restapi) ✗ openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 99999 -nodes
Generating a 2048 bit RSA private key
..............+++
....................................................+++
writing new private key to 'key.pem'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:cn
State or Province Name (full name) [Some-State]:cn
Locality Name (eg, city) []:cn
Organization Name (eg, company) [Internet Widgits Pty Ltd]:cn
Organizational Unit Name (eg, section) []:cn
Common Name (e.g. server FQDN or YOUR name) []:cn
Email Address []:cn
 
生成过程中多次提示输入一些信息,可以马马虎虎填写一下。
 
将生成的 cert.pem 和 key.pem 安装到/cert/目录下,为什么要放在这个目录呢,因为collidermain中硬编码读取下面两个文件。不放在这里就意味着要去修改collidermain中的代码,为了省事,暂且顺着它的方式来。
"/cert/cert.pem"
"/cert/key.pem"
 
 
 
安装 stunnle
sudo app-get install stunnle
配置
编辑 /usr/local/etc/stunnel/stunnel.conf
 
添加以下内容
[apprtc_main]
accept  = 443
connect = 8080
cert = /cert/cert.pem
 
[apprtc_auth]
accept  = 4431
connect = 8081
cert = /cert/cert.pem
 
 
安装golang
sudo app-get install golang
 
 
编译信令
在apprtc目录中
export GOPATH=$(shell pwd)
go build -o collidermain src/collider/collidermain/main.go
 
编译rfc5766-turn-server授权服务:apprtc_turn_auth
授权服务笔者没有找到源码,所以需要自己写,这里共享出笔者写golang版的代码。
编译方式如下
export GOPATH=$(shell pwd)
go build -o auth auth.go
 
 
 
 
修改apprtc中的代码
对apprtc/src做如下修改,但是IP地址要根据实际情况填写。修改之后必不可少的步骤是重新编译,千万别忘了。
 
diff --git a/src/app_engine/apprtc.py b/src/app_engine/apprtc.py
index dbe9d84..2acc179 100755
--- a/src/app_engine/apprtc.py
+++ b/src/app_engine/apprtc.py
@@ -292,6 +292,7 @@ def get_room_parameters(request, room_id, client_id, is_initiator):
 
   if room_id is not None:
     room_link = request.host_url + '/r/' + room_id
+    room_link = room_link.replace("http", "https")
     room_link = append_url_arguments(request, room_link)
     params['room_id'] = room_id
     params['room_link'] = room_link
diff --git a/src/app_engine/constants.py b/src/app_engine/constants.py
index 430a7a2..7d4dd73 100644
--- a/src/app_engine/constants.py
+++ b/src/app_engine/constants.py
@@ -16,8 +16,8 @@ TURN_BASE_URL = 'https://computeengineondemand.appspot.com'
 TURN_URL_TEMPLATE = '%s/turn?username=%s&key=%s'
 CEOD_KEY = '4080218913'
 
-ICE_SERVER_BASE_URL = 'https://networktraversal.googleapis.com'
-ICE_SERVER_URL_TEMPLATE = '%s/v1alpha/iceconfig?key=%s'
+ICE_SERVER_BASE_URL = 'https://10.58.60.236:4431'    # 'https://networktraversal.googleapis.com'
+ICE_SERVER_URL_TEMPLATE = '%s/turn?key=%s'             # '%s/v1alpha/iceconfig?key=%s'
 ICE_SERVER_API_KEY = os.environ.get('ICE_SERVER_API_KEY')
 
 # Dictionary keys in the collider instance info constant.
@@ -25,13 +25,13 @@ WSS_INSTANCE_HOST_KEY = 'host_port_pair'
 WSS_INSTANCE_NAME_KEY = 'vm_name'
 WSS_INSTANCE_ZONE_KEY = 'zone'
 WSS_INSTANCES = [{
-    WSS_INSTANCE_HOST_KEY: 'apprtc-ws.webrtc.org:443',
+    WSS_INSTANCE_HOST_KEY: '10.58.60.236:4432',   # 'apprtc-ws.webrtc.org:443',
     WSS_INSTANCE_NAME_KEY: 'wsserver-std',
     WSS_INSTANCE_ZONE_KEY: 'us-central1-a'
-}, {
-    WSS_INSTANCE_HOST_KEY: 'apprtc-ws-2.webrtc.org:443',
-    WSS_INSTANCE_NAME_KEY: 'wsserver-std-2',
-    WSS_INSTANCE_ZONE_KEY: 'us-central1-f'
+# }, {
+#     WSS_INSTANCE_HOST_KEY: 'apprtc-ws-2.webrtc.org:443',
+#     WSS_INSTANCE_NAME_KEY: 'wsserver-std-2',
+#     WSS_INSTANCE_ZONE_KEY: 'us-central1-f'
 }]
 
 WSS_HOST_PORT_PAIRS = [ins[WSS_INSTANCE_HOST_KEY] for ins in WSS_INSTANCES]
diff --git a/src/collider/collidermain/main.go b/src/collider/collidermain/main.go
index a499ada..5e164dd 100644
--- a/src/collider/collidermain/main.go
+++ b/src/collider/collidermain/main.go
@@ -6,7 +6,7 @@
 package main
 
 import (
-    "collider"
+    "collider/collider"
     "flag"
     "log"
 )
➜  apprtc git:(restapi) ✗
 
 
 
 
最后
由于整个过程过于繁琐,笔者在实验过程中写了Makefile,现也共享传来。这个Makefile在调试运行过程中缺失带来了很多便利,不用每次噼里啪啦的敲一堆命令。几乎包含了上述所有编译,运行的操作,有了此文件只需make  xxx 就行
 
➜  apprtc git:(restapi) ✗ cat Makefile
all: apprtc auth collidermain
 
apprtc:
  sudo grunt build --force
 
auth: auth.go env
    go build -o auth auth.go
 
collidermain: src/collider/collidermain/main.go env
    go build -o collidermain src/collider/collidermain/main.go
 
clean:
    rm auth
 
env:
    export GOPATH=$(shell pwd)
 
test_auth:
    curl http://localhost:8081/turn
    curl http://localhost:8081/v2/turn
 
 
run_apprtc:
    sudo ../google_appengine//dev_appserver.py ./out/app_engine --host 0.0.0.0    2>&1 | tee app.log
 
run_auth:
    sudo ./auth -port 8081
 
run_collidermain:
    sudo ./collidermain -port 4432 -room-server http://localhost:8080 2>&1 | tee collider.log
 
run_stunnel:
    sudo stunnel
 
run_turnserver:
    sudo turnserver
 
 
.PHONY: all test clean apprtc env
 
 
 
 
体验
 
参考文章
 
 
未完……

webrtc起步 - apprtc服务器搭建的更多相关文章

  1. p2p webrtc服务器搭建系列1: 房间,信令,coturn打洞服务器

    中继(relay) 在RTCPeeConnection中,使用ICE框架来保证RTCPeerConnection能实现NAT穿越 ICE,全名叫交互式连接建立(Interactive Connecti ...

  2. WebRTC 入门教程(二)| WebRTC信令控制与STUN/TURN服务器搭建

    WebRTC 入门教程(二)| WebRTC信令控制与STUN/TURN服务器搭建 四月 4, 2019 作者:李超,音视频技术专家.本文首发于 RTC 开发者社区,欢迎在社区留言与作者交流. htt ...

  3. AppRTC服务搭建(测试)

    提供一个在线的webrtc服务器测试,需要的朋友看看.https://www.webrtcserver.cn/ 服务器搭建环境各有不同在此参考前人经验差试一下. 运行AppRTC需要使用Google ...

  4. STUN/TURN服务器搭建

    目录 STUN/TURN服务器搭建 编译安装 配置使用 添加用户 启动server 测试 开机启动 参考 STUN/TURN服务器搭建 编译安装 编译安装 OpenSSL: sudo apt-get ...

  5. Git本地服务器搭建及使用详解

    Git本地服务器搭建及使用 Git是一款免费.开源的分布式版本控制系统.众所周知的Github便是基于Git的开源代码库以及版本控制系统,由于其远程托管服务仅对开源免费,所以搭建本地Git服务器也是个 ...

  6. ​Linux下的SVN服务器搭建

    ​Linux下的SVN服务器搭建 鉴于在搭建时,参考网上很多资料,网上资料在有用的同时,也坑了很多人 本文的目的,也就是想让后继之人在搭建svn服务器时不再犯错,不再被网上漫天的坑爹作品所坑害,故此总 ...

  7. 版本控制-svn服务器搭建和常用命令(centos 6.3)

    Svn是比较优秀的版本控制工具,虽然功能和性能上无法和Git媲美,但由于其容易搭建和使用的特性,所以在各个小公司还是很受欢迎的.使用Git可参考<版本控制-Git服务器搭建和常用命令使用> ...

  8. 版本控制-Git服务器搭建和常用命令使用

    Git是目前世界上最先进的分布式版本控制系统(没有之一).使用Svn的请参考<版本控制-svn服务器搭建和常用命令(centos 6.3)>,下面介绍Git的常用命令 常用命令 简单版 升 ...

  9. JAVA服务器搭建之问题总结

    负责维护公司产品的web服务器搭建与维护,最近遇到一下状况,今天在这里简单总结一下,希望对于刚刚一些刚入行的小伙伴有所帮助,避免再走弯路. 第一点:Tomcat内存设置: 一.常见的Java内存溢出有 ...

随机推荐

  1. CSS布局(五) 网页布局方式

    网页实质是块与块之间的位置,块挨着块,块嵌套块,块叠着块. 三种关系:相邻,嵌套,重叠. 下面介绍网页布局的常用几种方式 1.一列布局: 一般都是固定的宽高,设置margin : 0 auto来水平居 ...

  2. keras初涉笔记【一】

    安装keras依赖的库 sudo pip install numpy sudo pip install scipy sudo pip installl pyyaml sudo pipi install ...

  3. Flask從入門到入土(四)——登錄實現

    表單介紹 1.表單標籤 聲明表單的範圍,位於表單標籤中的元素將被提交 語法: <form>  </form> 屬性: Method(提交方式get,post) , Enctyp ...

  4. Python实现二分查找

    老生常谈的算法了. #!/usr/bin/python # -*- coding:utf-8 -*- # Filename: demo.py # 用python实现二分查找 def binarySea ...

  5. nyoj61 传纸条(一) dp

    思路:两人一个从左上角出发只能向右和向下,另一人从右下角出发只能向左和向上,可以看做两人都是从右下角出发,且只能向左和向上传纸条,并且两条路径不会相交,因为一个人只会传一次,那么随便画一个图就能知道两 ...

  6. JSP的内置对象以及作用域。

    最近在面试,一些基础的问题总是会被问到,虽然是基础,但是有些东西在工作中用的少,所以就有些记不清了,在面试的时候更因为紧张很容易造成原先知道的知识也会突然忘了的情况发生.所以在重新组织一下jsp的内置 ...

  7. python更新数据库脚本两种方法

    最近项目的两次版本迭代中,根据业务需求的变化,需要对数据库进行更新,两次分别使用了不同的方式进行更新. 第一种:使用python的MySQLdb模块利用原生的sql语句进行更新 import MySQ ...

  8. JVM笔记5-对象的访问定位。

    java虚拟机中指定一个栈内存的引用指向了堆内存中的对象.这样说只是笼统的说法.而指向堆内存中的对象就一定是栈引用所需要的那个对象吗?其实并不定. 这就需要知道对象的访问定位方式有两种: 1.使用句柄 ...

  9. centos7安装zabbix3.2.4

    系统:CentOS Linux release 7.2.1511 (Core) zabbix:3.2.4 一.yum -y install httpd mysql mysql-server mysql ...

  10. iBrand 产品工具包:Laravel Database Logger

    iBrand 社交新零售电商产品从2016年9月启动至今,已经趋于稳定,而且已经初步得到市场的检验,特别能抗住电商中秒杀时高并发的交易场景. 接下来我们团队会逐步开源一些正在使用的工具和解决方案,并且 ...