在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虚拟机进行安装,但 ...
随机推荐
- debian 6软件更新源列表
deb http://ftp.debian.org/debian/ squeeze main non-free contribdeb http://ftp.debian.org/debian/ squ ...
- 【spring data jpa】使用jpa进行update更新操作,避免空字段和更新后即时返回给前台的问题
修改操作 如果使用的JPA,应该是 findByUid之后 将新的值对old进行赋值,最后对old值进行flush(),即可完成更新,而不应该去更新新的实体. 示例代码: 以后补充
- HttpApplication理解
HttpApplication对象是经由HttpApplicationFactory.GetApplicationInstance(并最终调用HttpRuntime.CreateNonPublicIn ...
- ODATA4 及实现
ODATA4 的JAVASCRIPT 实现: http://jaydata.org/ ODATA4 的JAVA 项目 Apache Olingo:http://olingo.incubato ...
- 关于spring-data-jpa的排序问题
本测试基于springBoot框架实现. pom.xml文件: <project xmlns="http://maven.apache.org/POM/4.0.0" xmln ...
- 【Todo】Nodejs学习计划
/Users/baidu/Documents/Data/Interview/Web-Server开发/深入浅出Node.js-f46c.pdf /Users/baidu/Documents/Data/ ...
- Spark(十) -- Spark Streaming API编程
本文测试的Spark版本是1.3.1 Spark Streaming编程模型: 第一步: 需要一个StreamingContext对象,该对象是Spark Streaming操作的入口 ,而构建一个S ...
- WCF报错
1."没有终结点在侦听可以接受消息的 http://localhost:8084/Service1.svc.这通常是由于不正确的地址或者 SOAP 操作导致的.如果存在此情况,请参见 Inn ...
- 使用Nginx+uWSGI+Django方法部署Django程序(上)
Django的部署可以有很多方式,采用nginx+uwsgi的方式是其中比较常见的一种方式. 在这种方式中,我们的通常做法是,将nginx作为服务器最前端,它将接收WEB的所有请求,统一管理请求.ng ...
- Ubuntu 11.04 (Natty) 已经停止支持 但可以使用old-releases源了
Ubuntu 11.04 (Natty) 已经停止支持,但可以使用old-releases源了,先备份源列表文件: sudo cp /etc/apt/sources.list /etc/apt/sou ...