概述
我們在web客戶端使用sip協議時用的比較多的是sipml5庫和jssip庫。
但是sip協議比較重,又復雜,所以freeswitch內部就自定義了一個verto協議,方便在web頁面上使用音視頻服務。
verto協議通過websocket傳輸信令,協議內部數據格式為json,這樣比較符合互聯網開發人員的習慣,同時比sip協議更加輕量化。
freeswitch有一個endpoint模塊叫做mod_verto,是用來作為服務端的協議適配器。
freeswitch的源碼中有幾個支持verto協議的web客戶端實現,分別是verto demo、video_demo和verto communicator等,都是基於js實現的。
verto客戶端的源碼在freeswitch-1.8.7_master\html5\verto目錄下,用戶可以自行查看。
今天我們主要介紹一下verto communicator的安裝部署過程。
verto communicator
verto communicator的官方介紹頁面:https://freeswitch.org/confluence/display/FREESWITCH/Verto+Communicator 。
verto communicator是基於nodejs安裝部署的,源代碼目錄中已經有nodejs相關的工具配置文件,可以快速的安裝、部署、構建和運行verto communicator客戶端。
但是呵呵,這玩意用的人少,所以維護更新也少,安裝過程中大坑小坑很多。
坑一,nodejs不熟悉。先去學習nodejs的教程和基本使用方法。
坑二,npm的包安裝要區分全局和本地。先去學習npm工具的基本教程。
坑三,bower安裝依賴庫時,git鏈接各種問題。拆分命令,多次嘗試。
坑四,grunt對nodejs版本有要求。centos7默認的nodejs版本最高只有6.17,需要使用至少8+的版本。
唯一欣慰的一點就是,在verto communicator目錄下安裝成功過一次,再把整個目錄拷貝到其他地方,就可以直接使用了。
環境
centos:CentOS release 7.0 (Final)或以上版本
freeswitch:v1.8.7
GCC:4.8.5
安裝部署
進入verto communicator目錄
cd /root/freeswitch-1.8.7_master/html5/verto/verto_communicator
安裝npm工具
yum install npm
安裝nodejs版本管理工具n,安裝nodejs的8+版本並選定
npm install -g n
n 8
n lts
n
使用n選定nodejs8版本后,重啟ssh終端
安裝工具bower和grunt
npm install -g bower grunt
使用npm安裝依賴庫
npm install
使用bower安裝依賴庫,這一步巨坑無比
方法一,默認方法,但是無限失敗
bower --allow-root install
方法二,拆分依賴庫安裝步驟,最后再合並
訣竅是。。。多試幾次,然后祈禱。。。因為我第2次重裝的時候,怎么都是失敗
mv bower.json bower.json.back
bower --allow-root init
bower install --allow-root moment/moment@~2.9.0 --save
bower install --allow-root jquery@~2.1.4 --save
bower install --allow-root js-cookie/js-cookie@~1.4.1 --save
bower install --allow-root jquery-json@~2.5.1 --save
bower install --allow-root angular@~1.3.15 --save
bower install --allow-root angular-gravatar@~0.4.1 --save
bower install --allow-root bootstrap@~3.3.4 --save
bower install --allow-root angular-toastr@~1.4.1 --save
bower install --allow-root angular-sanitize@~1.3.15 --save
bower install --allow-root angular-route@~1.3.15 --save
bower install --allow-root bower-angular@~1.2.16 --save
bower install --allow-root angular-prompt@~1.1.1 --save
bower install --allow-root angular-animate@~1.3.15 --save
bower install --allow-root angular-cookies@~1.3.15 --save
bower install --allow-root angular-directive.g-signin@~0.1.2 --save
bower install --allow-root angular-fullscreen@~1.0.1 --save
bower install --allow-root ngstorage@~0.3.9 --save
bower install --allow-root humanize-duration#~3.10.0 --save
bower install --allow-root angular-timer@~1.3.3 --save
bower install --allow-root angular-tooltips@~0.1.21 --save
bower install --allow-root datatables@~1.10.8 --save
bower install --allow-root angular-bootstrap@~0.14.3 --save
bower install --allow-root mdbootstrap/bootstrap-material-design@~0.3.0 --save
bower install --allow-root angular-translate@~2.10.0 --save
bower install --allow-root angular-translate-loader-static-files@~2.10.0 --save
bower install --allow-root angular-click-outside@~2.9.2 --save
mv bower.json.back bower.json
修改bower.json文件:
"bootstrap-material-design": "~0.3.0"修改為 "bootstrap-material-design": "mdbootstrap/bootstrap-material-design#~0.3.0"
bower --allow-root install
使用grunt構建
grunt build --force
配置啟動
在安裝部署的所有步驟都成功的情況下,直接啟動
[root@localhost verto_communicator]# grunt serve
Running "serve" task
Running "wiredep:app" (wiredep) task
Running "concurrent:server" (concurrent) task
Running "copy:styles" (copy) task
Copied 1 file
Done, without errors.
Execution Time (2021-09-16 09:19:36 UTC+8)
loading tasks 372ms ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇ 95%
loading grunt-contrib-copy 6ms ▇ 2%
copy:styles 13ms ▇▇ 3%
Total 391ms
Running "postcss:dist" (postcss) task
>> 1 processed stylesheet created.
Running "browserSync:livereload" (browserSync) task
[Browsersync] Access URLs:
------------------------------------
Local: https://localhost:9001
External: https://192.168.0.152:9001
------------------------------------
[Browsersync] Serving files from: ../js/src/
[Browsersync] Serving files from: ./js
[Browsersync] Serving files from: .
[Browsersync] Watching files...
Running "watch" task
Waiting...
測試
瀏覽器打開URL:https://192.168.0.152:9001
按照freeswitch server的注冊信息配置字段。
其中,websocket URL地址必須使用域名方式才能正常登陸,可以通過修改本地host,將域名直接指向fs注冊服務器地址的方式來實現。
總結
verto協議是基於json的輕量化協議,在web應用中使用和實現都非常方便。
其中verto communicator在nodejs環境的安裝部署過程中問題太多,而且難以解決,不推薦使用。(也可能是因為本人對nodejs不熟悉,如果有更好的解決方案,請留言,多謝)
空空如常
求真得真