在root目录下先放好自定义的constants.py文件再docker run
同时记得修改PUBLIC_IP
可以跨wifi通信
docker pull piasy/apprtc-server
docker run --name apprtc -p 8080:8080 -p 8089:8089 -p 3478:3478 -p 3478:3478/udp -p 3033:3033 --expose=59000-65000 -e PUBLIC_IP=47.88.63.197 -v /root:/apprtc_configs -it piasy/apprtc-server
其中;
-e 设置环境变量的,
-v, --volume=[host-src:]container-dest[:<options>]: Bind mount a volume.映射与共享用
附: -v选项
运行命令:docker run -it -v /home/xqh/myimage:/data ubuntu /bin/bash
其中的 -v 标记 在容器中设置了一个挂载点 /data(就是容器中的一个目录),并将主机上的 /home/xqh/myimage 目录中的内容关联到 /data下。
这样在容器中对/data目录下的操作,还是在主机上对/home/xqh/myimage的操作,都是完全实时同步的,因为这两个目录实际都是指向主机目录。
AppRTC 需要三个 Server:
- Room Server: 负责处理加入房间、获取配置等请求;
- Signal Server: 长连接服务器,用于聊天过程中实时下发信息;
- TURN/STUN Server: 打洞服务器,用于 NAT 打洞;
About port expose:
- 8080 is used for room server;
- 8089 is used for signal server;
- 3033 is used for ICE server;
- 3478 and 59000-65000 is used for TURN/STUN server;
注意一定要开放 3478 udp 端口,否则 STUN Binding 请求进不去;
AppRTC Android demo 中,会尝试从房间配置中读取 pc_config 域,以取得 TURN/STUN Server 信息;如果没有获取到,就会向配置中的 ice_server_url 指向的服务器获取 TURN/STUN Server 信息。但 apprtc 的配置说明中,让我们把 TURN/STUN Server 配置写在 TURN_SERVER_OVERRIDE中,这是不行的,因为客户端的逻辑并不会读取 TURN_SERVER_OVERRIDE 这个域,此外 Android demo 读取 pc_config 的代码中,无法正确把 TURN Server 的用户名解析出来,所以我们不得不自己搭一个 ICE Server,这会多一次网络请求
示例的constants.py:
ICE_SERVER_BASE_URL, ICE_SERVER_URL_TEMPLATE and WSS_INSTANCES has been modified.
因此我们还需要第四个 Server:ICE Server。它用于下发 TURN/STUN Server 配置信息,代码如下
几点说明:
- 这里面有两个配置写死了:key = '4080218913',用户名 ninefingers,它们都是在部署 Coturn 时配置的;
- username/credential 并不是 Coturn 创建用户的 username/password,而是按照上述逻辑计算出来的值,否则 Coturn 会报错 401 Unauthorized;
- 上面的 ICE Server 部署之后,Android demo 请求时会报 404,最终定位是因为 demo 用 HttpURLConnection 时设置了 connection.setDoOutput(true);,注释掉就好了,详见这个 commit;
附:运行日志
log file opened: /var/log/turn_15_2017-09-12.log
RFC 3489/5389/5766/5780/6062/6156 STUN/TURN Server
Version Coturn-4.5.0.6 'dan Eider'
Max number of open files/sockets allowed for this process: 65536
Due to the open files/sockets limitation,
max supported number of TURN Sessions possible is: 32500 (approximately)
==== Show him the instruments, Practical Frost: ====
0: TLS supported
0: DTLS supported
0: DTLS 1.2 supported
0: TURN/STUN ALPN supported
0: Third-party authorization (oAuth) supported
0: GCM (AEAD) supported
0: OpenSSL compile-time version: OpenSSL 1.0.2g 1 Mar 2016 (0x1000207f)
0: SQLite is not supported
0: Redis is not supported
0: PostgreSQL is not supported
0: MySQL is not supported
0: MongoDB is not supported
0: Default Net Engine version: 3 (UDP thread per CPU core)
=====================================================
0: Listener address to use: 0.0.0.0
0: Domain name:
0: Default realm: apprtc
0: Relay address to use: 0.0.0.0
0: pid file created: /var/run/turnserver.pid
0: IO method (main listener thread): epoll (with changelist)
0: WARNING: I cannot support STUN CHANGE_REQUEST functionality because only one IP address is provided
0: Wait for relay ports initialization...
0: relay 0.0.0.0 initialization...
0: relay 0.0.0.0 initialization done
0: Relay ports initialization done
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=0 created
0: IPv4. SCTP listener opened on : 0.0.0.0:3478
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=1 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=2 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=3 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=4 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=5 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=6 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=7 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=8 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=9 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=10 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=11 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=12 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=13 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=14 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=15 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=16 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=17 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=18 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=19 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=20 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=21 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=22 created
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: IO method (general relay thread): epoll (with changelist)
0: turn server id=23 created
0: IPv4. UDP listener opened on: 0.0.0.0:3478
0: IPv4. TCP listener opened on : 0.0.0.0:3478
0: Total General servers: 24
0: IO method (auth thread): epoll (with changelist)
0: IO method (auth thread): epoll (with changelist)
0: IO method (auth thread): epoll (with changelist)
0: IO method (auth thread): epoll (with changelist)
0: IO method (auth thread): epoll (with changelist)
0: IO method (auth thread): epoll (with changelist)
0: IO method (auth thread): epoll (with changelist)
0: IO method (auth thread): epoll (with changelist)
0: IO method (auth thread): epoll (with changelist)
0: IO method (auth thread): epoll (with changelist)
0: IO method (auth thread): epoll (with changelist)
0: IO method (auth thread): epoll (with changelist)
0: IO method (admin thread): epoll (with changelist)
server started
参考:
- 在 Mac/Windows 系统中使用 Laradock 搭建基于 Docker 的 Laravel 开发环境 (改)
开篇 Use Docker First And Learn About It Later 简介 Laradock 是为 Docker 提供的完整 PHP 本地开发环境,和 Homestead 一样提供 ...
- win10搭建基于docker的odoo开发环境
- 在windows环境里,用Docker搭建Redis开发环境(新书第一个章节)
大家都知道高并发分布式组件的重要性,而且如果要进大厂,这些技术不可或缺.但这些技术的学习难点在于,大多数项目里的分布式组件,都是搭建在Linux系统上,在自己的windows机器上很难搭建开发环境,如 ...
- Docker最全教程之使用Docker搭建Java开发环境(十七)
前言 Java是一门面向对象的优秀编程语言,市场占有率极高,但是在容器化实践过程中,发现官方支持并不友好,同时与其他编程语言的基础镜像相比(具体见各语言镜像比较),确实是非常臃肿. 本篇仅作探索,希望 ...
- Mac上通过docker配置PHP开发环境
这篇文章介绍的内容是关于Mac上通过docker配置PHP开发环境,有着一定的参考价值,现在分享给大家,有需要的朋友可以参考一下 更多PHP相关知识请关注我的专栏PHPzhuanlan.zhihu. ...
- 如何使用Docker部署PHP开发环境
本文主要介绍了如何使用Docker构建PHP的开发环境,文中作者也探讨了构建基于Docker的开发环境应该使用单容器还是多容器,各有什么利弊.推荐PHP开发者阅读.希望对大家有所帮助. 环境部署一直是 ...
- 最新基于adt-bundle-windows-x86的android开发环境筹建
最新基于adt-bundle-windows-x86的android开发环境搭建 某系统要配套做一个android客户端,来一次android开发环境快速搭建,系统Win7,具体步骤如下: 1.下载j ...
- 基于MDK的ARM-GCC开发环境建立及新唐M0的HID类设备的C++开发
一,下载安装测试arm-none-eabi-gcc编译工具链 1,查看arm-none-eabi-gcc编译工具版本 打开网页:https://sourcery.mentor.com/G ...
- 如何用docker安装laravel开发环境
如何用docker安装laravel开发环境 看laravel框架的官方文档安装部分时,发现需要安装特别多软件,估计还有许多复杂的配置,官方推荐使用Laravel Homestead虚拟机进行安装,但 ...
随机推荐
- Android 智能指针学习 一
Android5.1 中智能指针涉及的文件如下: system/core/include/utils/RefBase.h system/core/libutils/RefBase.cpp system ...
- ARM“庖丁解牛”之存储器管理单元MMU
转:http://blog.sina.com.cn/s/blog_a07635070101bcbt.html 最近笔者详细地学习了由杜春雷老师编写的<ARM体系结构与编程>.对ARM存储管 ...
- nhibernate change connection
http://stackoverflow.com/questions/4335827/changing-nhibernate-connectionstring http://stackoverflow ...
- Linq 简明教程
一个简单的实例 static void Main(string[] args) { string[] names = { "Alonso", "Zheng", ...
- gulp的入门浅析
阅读目录 介绍gulp 安装gulp gulpfile.js 运行gulp 介绍gulp的api 介绍gulp gulp是基于Nodejs的自动任务运行器, 她能自动化地完成 javascript/c ...
- 【AS3 Coder】任务九:游戏新手引导的制作原理(下)
在上一篇教程中,我们了解了一套我自创的新手引导管理框架的使用原理,那么在本篇教程中,我们将考虑新手引导制作中可能遇到的一些棘手问题及探讨其解决方案.Are you ready my baby? Let ...
- NYOJ 1058 部分和问题 【DFS】
部分和问题 时间限制:1000 ms | 内存限制:65535 KB 难度:2 描写叙述 给定整数a1.a2........an,推断能否够从中选出若干数.使它们的和恰好为K. 输入 首先,n和k ...
- C++中的INL(转)
inl 文件是内联函数的源文件. 内联函数通常在c++头文件中实现,但有的时候内联函数较多或者出于一些别的考虑(使头文件看起来更简洁等), 往往会将这部分具体定义的代码添加到INL文件中,然后在该头文 ...
- C++——动态分配内存问题
class Obj { public: float score; ]; }; class Result { public: int id; ]; Obj obj[]; }; 合法,可动态分配内存给Re ...
- Eclipse 安装应用SVN地址
SVN插件下载地址及更新地址,你根据需要选择你需要的版本.现在最新是1.8.xLinks for 1.8.x Release:Eclipse update site URL: http://subcl ...