基于licode搭建webrtc服务器

0. 前言

licode官网文档安装教程十分简单, 但是实际搭建过程是很艰辛的. 官方文档没有提示说会遇到什么样的问题, 实际过程中可能遇到各种各样的问题, 在解决的时候费时费力, 我就总结一下自己在安装搭建过程中遇到的问题.

注: 最大的问题就是网络问题, 整个安装过程是边下载资源边安装的, 资源基本都是国外的, 因为墙的缘故, 可能会遇到想不到的错误.

 

1. 环境

系统: ubuntu16.04.6 ( ubuntu14.04.6也可以 )
用户: root
执行时最好加 sudo
官方安装教程地址: https://licode.readthedocs.io/en/master/from_source/

 

2. 搭建

下面是我引用licode官方教程中一些主要步骤内容

Clone Licode
Let's start by cloning the Licode repository
git clone https://github.com/lynckia/licode.git
cd licode

The repository contains scripts for the rest of the steps of this guide.
Install dependencies
This step installs the dependencies of all the Licode components. This is the only step that depends on your OS
./scripts/installUbuntuDeps.sh

 

Install Licode
Here we will install all the Licode components in your computer.
./scripts/installNuve.sh
./scripts/installErizo.sh

Install basicExample
The basicExample is a really simple node-based web application that relies on Licode to provide a videoconferencing room.
./scripts/installBasicExample.sh

Start Licode!
At this points, you have successfully installed all the Licode components in your computer and also a simple application that will let you try it. Let's use the convenience script to start all Licode components:
./scripts/initLicode.sh

After that, we just have to start our node application, we also have a script for that:
./scripts/initBasicExample.sh

Now you can connect to http://localhost:3001 with Chrome or Firefox and test your basic videoconference example!
What's next?
Well you now have a taste of what Licode can do. You can start by modifying basicExample. You can find the code in licode/extras/basic_example: * basicServer.js is the node.js server that manages the communication between the clients and Nuve. Here you can add your own methods using the server side API (NuveAPI)
Head to Licode Architecture for more information about different Licode components, or start developing your custom service getting into the client or server APIs.

 

注: 如果可以FQ, 而且网速还可以, 将会减少很多下载安装的问题
网络问题可能会报一些连接超时问题或找不到包, 建议重试或者更换网络.


licode中nvm需要安装的node版本是6.14.4, 但我这边使用nvm ls-remote 命令看到远程库中只有1.x.x~3.x.x版本.
(其实远程库应该是有nodejs版本的, iojs和nodejs在两个不同地址的版本库, 很可能因为墙的原因, 导致版本库加载不出来)
1.x.x~3.x.x 是iojs版本
0.x.x 以及4.x.x~10+.x.x是nodejs版本


开始尝试更改licod路径下的.nvmrc配置, 把6.14.4版本号换成3.1.0版本号.
于是nvm安装的为iojs3.1.0, 前面都很成功.
但是到后面编译时发现
安装低版本的node发现执行 ./scripts/installNuve.sh 会报错
之后又更改安装脚本代码, 更换了国内源, 可以加载iojs版本和nodejs版本, 成功安装了6.14.4版本nodejs

在nvm.sh(路径: ./licode/build/libdeps/nvm/)中修改源地址为国内源 如: https://npm.taobao.org/dist

 

或者在installUbuntuDeps.sh中对应位置添加如下框起来的代码(临时环境变量, 把国内源临时添加上去)
export NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/dist

 

这样就可以找到合适版本的nodejs了.

nodejs可执行程序路径(./licode/build/libdeps/nvm/versions/node/v6.14.4/bin/)

注: iojs版本对应的是(./licode/build/libdeps/nvm/versions/io.js/vx.x.x/bin)

npm是安装node时一块儿安装的.是和node绑定的. 在node可执行程序对应的路径下.
npm的可执行程序路径(./licode/build/libdeps/nvm/versions/node/v6.14.4/bin/)
npm使用的源默认是国外的, 速度可能很慢, 很容易发生中连接失败中断错误.
我尝试更换国内源

1 # 更换源地址, 如国内源: https://registry.npm.taobao.org
2 npm config set registry 源的访问地址
3 
4 # 查看配置源地址
5 npm config get registry

注: 1. 更换源地址使用绝对路径或相对路径(保证使用的是licode下的npm), 否则直接用npm命令使用的是系统的npm, 而不是licode的npm.
     2. 使用tabao源虽然解决了6.14.4版本问题, 但是发现后面的过程很慢很慢, 反而换成原来的很快.


安装conan部分
conan错误, 这个是安装conan错误, 首先去python的dist-packages目录下, 删除setuptools-3.3.egg-info文件夹, 然后再使用pip命令下载setuptools, 后面的就交给licode的安装脚本就行了.

pip3 install setuptools -U
Downloading setuptools-41.2.0-py2.py3-none-any.whl (576kB): 576kB downloaded
Installing collected packages: setuptools
Found existing installation: setuptools 3.3
Not uninstalling setuptools at /usr/lib/python3/dist-packages, owned by OS
Successfully installed setuptools
Cleaning up...

root@ubuntu:~/licode# cd /usr/lib/python3/dist-packages/
root@ubuntu:/usr/lib/python3/dist-packages# sudo rm -fr setuptools-3.3.egg-info/
root@ubuntu:~/licode# pip3 install setuptools -U

  

下载的各种依赖环境(都是脚本自动下载安装的, 可能有些因网络问题等会失败,可以自行下载对应压缩包放入对应路径):
详细大小:

第一步./scripts/installUbuntuDeps.sh执行成功.

或者

第二步./scripts/installNuve.sh执行成功

 

第三步 ./scripts/installErizo.sh
编译时遇到错误: 提示识别错误, ld共享库损坏

执行ld -v 查看版本

更新ld.

1 apt-get update
2 apt-get install binutils-2.26
3 // 默认是把新版本的安装到了 /usr/lib/binutils-2.26/ 下了, 把旧的/usr/bin/ld 备份, 建立新的软连接 /usr/bin/ld --> /usr/lib/binutils-2.26/bin/ld
4 
5 // 也可以用源码安装(源码安装三部曲): 
6 // 源码地址: https://ftp.gnu.org/gnu/binutils/
7 // ./configure --prefix=/xx/xx 执行configure时添加安装路径.

更新后查看版本

 

 

下载nodejs的header

下载nodejs的header失败, 其实这个是源的问题,因为国外源, 导致访问不到.( 另因: 我手动点这个地址, 发现进去需要输入验证码, 很有可能是因为需要输入验证码, 才导致找不到资源.)

在node-gyp可执行程序的路径下执行如下命令手动下载安装(通过国内源下载) (路径:./licode/build/libdeps/nvm/versions/node/v6.14.4/bin/)

1 ./node-gyp install --dist-url https://npm.taobao.org/mirrors/node

 


执行成功打印

注: node-gyp文档地址: https://www.npmjs.com/package/node-gyp

 

第三步 ./scripts/installErizo.sh 执行成功.

 

 

 

不常见错误:
执行npm时可能出现的报错:
报错: CERT_UNTRUSTED
解决办法: ssl验证问题,使用下面的命令取消ssl验证即可解决 npm config set strict-ssl false

 

nvm相关
nvm的github地址: https://github.com/nvm-sh/nvm
nvm 常用命令
● nvm install stable 安装最新稳定版 node
● nvm install <version> 安装指定版本,如:安装v4.4.0,nvm install v4.4.0
● nvm uninstall <version> 删除已安装的指定版本,语法与install类似
● nvm use <version> 切换使用指定的版本node
● nvm ls 列出所有安装的版本
● nvm alias default <version> 如: nvm alias default v11.1.0


其它
window 打开浏览器
cmd /c start http://www.baidu.com

linux打开浏览器
x-www-browser http://www.baidu.com

中科大源
http://npmreg.mirrors.ustc.edu.cn

-----------------------------------------------------------------------------------------------------

目前通过谷歌浏览器和69版本的火狐浏览器无法使用摄像头采集, 也不能正常拉流, 推测是因为安全问题, 需要使用https才能正常使用.

posted @ 2019-09-21 11:27  丁方  阅读(4735)  评论(0编辑  收藏  举报