OWT-Server 部署安装

862 阅读4分钟

OWT-Server 部署安装

项目中需要使用MCU模式WebRTC 在服务器进行合流,播放设备性能差,无法同时播放4路画面。

找了一圈支持MCU的开源服务器。能商用的就2个:

  • owt-server
  • Licode
  • Kurenoto (停止维护)

owt-server 会好一些。有些公司商业项目用这个的,而且还支持H265

其他的开源都不支持:

  • Pion
  • Jauns
  • Jitsi
  • Mediasoup
  • OpenVidu

备注:Jauns这个开源库,只支持音频混合。不支持视频混合

编译环境

我在国内的服务器没有编译出来过,就放上过程了。

我在Ubuntu 20.04版本上编译不通过。后来是用的Ubuntu 18.04可以编译,但编译到chrome的时候,过不去。

我就使用docker hub上别人编译的镜像文件了。

不知道为什么,我vpn开全局代理也不行。他有些代码好像是golang写的,我看里面直接走了代理,go本身认识代理不安全。好像不让下载,验证这块儿是google服务器在做的。

我看代码的时候好像是这么回事儿,后面因为国外服务器没有。就不往下编译了。

碰到过类似问题的人,希望可以给我解答一下

使用Docker 运行

  1. 下载docker镜像:

docker pull lmshao/owt-server

  1. Linux在根目录创建 owt-server文件夹:

cd ~ && mkdir owt-server

  1. 进入 owt-server目录:

cd owt-server

  1. 创建 webrtc_agent文件夹:

mkdir webrtc_agent

  1. 创建 portal文件夹:

mkdir portal

  1. 创建文件 agent.toml:

    vi webrtc_agent

    文件内容如下:

[agent]
#Max processes that agent can run
maxProcesses = 13 #default: 13#Number of precesses that agent runs when it starts. 1 <= prerunProcesses <= maxProcesses.
prerunProcesses = 2 #default: 2
​
​
[cluster]
name = "owt-cluster"#The number of times to retry joining if the first try fails.
join_retry = 60 #default: 60#The interval of reporting the work load
report_load_interval = 1000 #default: 1000, unit: millisecond#The max network load under which this worker can take new tasks.
max_load = 0.85 #default: 0.85#The bandwidth of network-interface used for WebRTC peerconnections. 
network_max_scale = 1000 #unit: Mbps
​
​
[capacity]
#The ISP list this agent is able to handle.
#If the ISP list is set to be non-empty, only the creating token requests with preference.ips being matched with one element of this list will be scheduled to this agent.
isps = [] #default: [], which means all ISPs.
#The region list this agent prefers to handle
#If the region list is set to be non-empty, the creating token requests with preference.region being matched with one element of this list will be priorly scheduled to this agent.
regions = [] #default: [], which means all regions.
​
​
[rabbit]
host = "localhost" #default: "localhost"
port = 5672 #default: 5672[internal]
#The IP address used for internal-cluster media spreading. Will use the IP got from the 'network_interface' item if 'ip_address' is not specified or equal to "".
ip_address = "" #default: ""#The network interface used for internal-cluster media spreading. The first enumerated network interface in the system will be adopted if this item is not specified.
# network_interface = "eth0" # default: undefined# The internal listening port range, only works for TCP now
maxport = 0 #default: 0
minport = 0 #default: 0#########################################################################################
[webrtc]
#The network inferface all peer-connections will be established through. All network interfaces in the system will be adopted if this item is not specified or specified with an empty array.
##Valid value is an array of objects that has two properties: name and replaced_ip_address. name is the name of network interface that will be used, replaced_ip_address is the IP address used for replacing the internal IP address in locally generated SDP's and ICE candidates during establishing the peer-connection(useful when behind NATs). replaced_ip_address is optional, if it is not specified, IP address from corresponding network interface will not be replaced.
#Example of valid value: [{name = "eth1"}, {name = "eth2", replaced_ip_address = "192.0.2.2"}].
network_interfaces = [{name="eth0",replaced_ip_address="192.168.100.1"}]  # default: []keystorePath = "./cert/certificate.pfx"
#note, this won't work with all versions of libnice. With 0 all the available ports are used# The webrtc port range
maxport = 0 #default: 0
minport = 0 #default: 0#STUN server IP address and port to be used by the server.
#if "" is used, the address is discovered locally
stunport = 0 #default: 0
stunserver = "" #default: ""#ThreadPool worker numbers for peer connection
num_workers = 24 #default: 24
  1. network_interfaces = [{name="eno1",replaced_ip_address="192.168.100.1"}] # default: [] 内容替换为本机的网卡名称ip地址

    • name="eno1"
    • replaced_ip_address="192.168.100.1"
  2. 创建文件 portal.toml

vi portal/portal.toml

这里网卡地址一定要eth0, 不然会报错。错误信息: No scheduler for purpose: webrtc

文件内容如下:

[portal]
keystorePath = "./cert/certificate.pfx"
hostname = "" #default: ""
ip_address = "192.168.100.1" #default: ""
# Port that the socket.io server listens at.
port = 8080 #default: 8080
ssl = true #default: true
force_tls_v12 = false #default: false, tls1 and tls1.1 will not be allowed if set to true
#The network inferface the socket.io will be bound to in case portal.ip_address (the 'ip_address' item above) is not specified or equal to "".
# networkInterface = "eth1"
# How many seconds before Socket.IO client sending a new ping packet. This value might be overwrote by client side.
# ping_interval = 25 #default: undefined
# How many seconds without a pong packet to consider the Socket.IO connection closed. This value might be overwrote by client side.
# ping_timeout = 60 #default: undefined
# Life time for reconnection ticket. Unit: second.
reconnection_ticket_lifetime = 600 #default: 600
# Client will leave conference if it cannot reconnect to Socket.IO server after |reconnection_timeout| seconds.
reconnection_timeout = 60 #default: 60
#default: *, allow cross origin request share list. Add http(s)://web-app-server-ip-or-hostname:port to cors list in product deployment, example: ["http://web-app-server-ip-or-hostname:3001", "https://web-app-server-ip-or-hostname:3004"].
cors = ["*"]
​
​
[cluster]
name = "owt-cluster"#The number of times to retry joining if the first try fails.
join_retry = 60 #default: 60#The interval of reporting the work load
report_load_interval = 1000 #default: 1000, unit: millisecond#The max CPU load under which this worker can taks new tasks.
max_load = 0.85 #default: 0.85
​
​
[capacity]
#The ISP list this portal is able to handle
#If the ISP list is set to be non-empty, only the creating token requests with preference.ips being matched with one element of this list will be scheduled to this portal.
isps = [] #default: [], which means all ISPs.
#The region list this portal prefers to handle
#If the region list is set to be non-empty, the creating token requests with preference.region being matched with one element of this list will be priorly scheduled to this portal.
regions = [] #default: [], which means all regions.
​
​
[rabbit]
host = "localhost" #default: "localhost"
port = 5672 #default: 5672[mongo]
dataBaseURL = "localhost/owtdb" #default: "localhost/owtdb"
  1. ip_address = "192.168.100.1" #default: ""替换成本机IP地址
  1. 运行docker:
docker run -d --name owt-server \
    -p 3004:3004 \
    -p 8080:8080 \
    -p 15672:15672 \
    -p 3300:3300 \
    -v ~/owt-server/portal/portal.toml:/root/dist/portal/portal.toml \
    -v ~/owt-server/webrtc_agent/agent.toml:/root/dist/webrtc_agent/agent.toml \
    lmshao/owt-server
​
  1. 进入 docker容器

docker exec -it owt-server /bin/bash

  1. 输入命令,初始化owt和启动服务:

(cd dist && ./bin/init-all.sh && ./bin/start-all.sh)

  1. 第一次安装,需要升级socket.io协议,激活信令服务器:

访问地址:https://192.168.100.1:8080/socket.io/?EIO=3&transport=polling&t=N2UmsIn

把地址的IP192.168.100.1换成你自己的本机ip

如果已经执行过了,就不需要再访问。第一次安装的时候执行一次即可

  1. 访问管理后台,注意启动服务时有个sampleServiceId和sampleServiceKey,打开页面会要求输入这个信息:

访问地址:https://192.168.1.4:3300/console

sampleServiceIdsampleServiceKey两个字段。在执行 第12步操作的时候,会在日志中打印出来。

也可以进入docker容器手动再获取,步骤如下:

  • 进入窗口:docker exec -it owt-server /bin/bash
  • 执行:root/dist/management_api/init.sh
  1. 打开 owt-server默认页面:

地址:https://192.168.1.4:3004/

192.168.1.4 替换成 本机IP