当前位置:   article > 正文

Ubuntu16.04搭建webrtc服务器_webrtc-streamer 在ubuntu16.04上跑不起来

webrtc-streamer 在ubuntu16.04上跑不起来

本人查阅无数资料,历时3周搭建成功

一、服务器组成

  1. AppRTC 房间+Web服务器 https://github.com/webrtc/apprtc
  2. Collider 信令服务器,在AppRTC源码里
  3. CoTurn coturn打洞+中继服务器 
  4. Nginx 服务器,用于Web访问代理和Websocket代理。


AppRTC 房间+Web服务器使用python+js语言
AppRTC Collider信令服务器采用go语言
Coturn 采用C语言
在部署到公网时需要通过Nginx做Web和Websocket的代理连接

二、安装步骤

  1. 安装虚拟机
    1. 使用VMware虚拟机安装ubuntu 16.04 
    2. WMware安装过程中的问题及解决方法
      1. 完美解决ubuntu18.04下vi不能使用方向键和退格键
        【Linux】完美解决ubuntu18.04下vi不能使用方向键和退格键_ubuntu方向键变字母-CSDN博客
      2. Ubuntu 16.04 开启root用户和使用root用户登陆
        Ubuntu 16.04 开启root用户和使用root用户登陆_ubuntu 16.04 怎么用root登录-CSDN博客
      3. VMware虚拟机和主机间复制粘贴共享剪贴板
        VMware虚拟机和主机间复制粘贴共享剪贴板 - 知乎
  2.  准备工作
    1. 安装vim
      sudo apt‐get install vim
    2. 安装ssh
      sudo apt‐get install openssh‐server
    3. 安装ifconfig工具
      sudo apt‐get install net‐tools
      sudo apt‐get install iputils‐ping
    4. 更新源
      1. 备份source.list源
        sudo mv /etc/apt/sources.list /etc/apt/sources.list.old
      2. 执行命令打开sourcse.list文件
        sudo vim /etc/apt/sources.list
      3. 复制以下源到sources.list

        1. # deb cdrom:[Ubuntu 16.04 LTS _Xenial Xerus_ ‐ Release amd64
        2. (20160420.1)]/ xenial main restricted
        3. deb‐src http://archive.ubuntu.com/ubuntu xenial main restricted #Added
        4. by software‐properties
        5. deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
        6. deb‐src http://mirrors.aliyun.com/ubuntu/ xenial main restricted
        7. multiverse universe #Added by software‐properties
        8. deb http://mirrors.aliyun.com/ubuntu/ xenial‐updates main restricted
        9. deb‐src http://mirrors.aliyun.com/ubuntu/ xenial‐updates main
        10. restricted multiverse universe #Added by software‐properties
        11. deb http://mirrors.aliyun.com/ubuntu/ xenial universe
        12. deb http://mirrors.aliyun.com/ubuntu/ xenial‐updates universe
        13. deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
        14. deb http://mirrors.aliyun.com/ubuntu/ xenial‐updates multiverse
        15. deb http://mirrors.aliyun.com/ubuntu/ xenial‐backports main restricted
        16. universe multiverse
        17. deb‐src http://mirrors.aliyun.com/ubuntu/ xenial‐backports main
        18. restricted universe multiverse #Added by software‐properties
        19. deb http://archive.canonical.com/ubuntu xenial partner
        20. deb‐src http://archive.canonical.com/ubuntu xenial partner
        21. deb http://mirrors.aliyun.com/ubuntu/ xenial‐security main restricted
        22. deb‐src http://mirrors.aliyun.com/ubuntu/ xenial‐security main
        23. restricted multiverse universe #Added by software‐properties
        24. deb http://mirrors.aliyun.com/ubuntu/ xenial‐security universe
        25. deb http://mirrors.aliyun.com/ubuntu/ xenial‐security multiverse

      4. 保存后更新源 sudo apt‐get update
      5. 安装git
        sudo apt‐get install git
  3. 安装go
    1. ubuntu安装、升级、卸载golang

      https://blog.51cto.com/u_14480168/6343832

    2. golang1.15下载地址
      https://studygolang.com/dl/golang/go1.15.linux-amd64.tar.gz

  4. 开启trun服务

    nohup turnserver -L 192.168.101.36 -a -u vrviu:viu@1234 -v -f -r nort.gov &
    nohup $GOPATH/bin/collidermain ‐port=8089 ‐tls=false  ‐room‐server="http://192.168.101.36:8090" &

  5. 安装python工具
    1. 下载setuptools‐0.6c11‐py2.7.egg

       https://pypi.python.org/packages/2.7/s/setuptools/setuptools-0.6c11-py2.7.egg#md5=fe1f997bc722265116870bc7919059ea

    2. 下载pip‐1.5.4.tar.gz
      https://pypi.python.org/packages/source/p/pip/pip-1.5.4.tar.gz#md5=834b2904f92d46aaa333267fb1c922bb
    3. python2.7源码安装requests模块 https://www.cnblogs.com/nhxuan/p/17275502.html
      https://pypi.python.org/packages/5b/0b/34be574b1ec997247796e5d516f3a6b6509c4e064f2885a96ed885ce7579/requests-2.12.4.tar.gz

  6. 安装cnpm
    1. npm install -g cnpm@5.2.0 --registry=http://registry.npm.taobao.org/
  7. 修改配置文件
    配置防火墙,允许访问8090端口(tcp,此端口用于web访问)
    配置文件修改(主要是配置apprtc对应的conturn和collider相关参数 

    vim /root/webrtc/apprtc/out/app_engine/constants.py

    修改后(填的都是外网IP,为了适合更多数朋友测试,我这里用的是内网的环境,在公网部署填入公网IP即可)
    的完整配置文件。
     

    1. # Copyright 2015 Google Inc. All Rights Reserved.
    2. """AppRTC Constants.
    3. This module contains the constants used in AppRTC Python modules.
    4. """
    5. import os
    6. # Deprecated domains which we should to redirect to REDIRECT_URL.
    7. REDIRECT_DOMAINS = [
    8. 'apprtc.appspot.com', 'apprtc.webrtc.org', 'www.appr.tc'
    9. ]
    10. # URL which we should redirect to if matching in REDIRECT_DOMAINS.
    11. REDIRECT_URL = 'https://appr.tc'
    12. ROOM_MEMCACHE_EXPIRATION_SEC = 60 * 60 * 24
    13. MEMCACHE_RETRY_LIMIT = 100
    14. LOOPBACK_CLIENT_ID = 'LOOPBACK_CLIENT_ID'
    15. # Turn/Stun server override. This allows AppRTC to connect to turn servers
    16. # directly rather than retrieving them from an ICE server provider.
    17. #ICE_SERVER_OVERRIDE = None
    18. # Enable by uncomment below and comment out above, then specify turn and stun
    19. ICE_SERVER_OVERRIDE = [
    20. {
    21. "urls": [
    22. "turn:192.168.101.64:3478?transport=udp",
    23. "turn:192.168.101.64:3478?transport=tcp"
    24. ],
    25. "username": "vrviu",
    26. "credential": "viu@1234"
    27. },
    28. {
    29. "urls":[
    30. "stun:192.168.101.64:3478"
    31. ]
    32. }
    33. ]
    34. ICE_SERVER_BASE_URL = 'https://192.168.101.64'
    35. ICE_SERVER_URL_TEMPLATE = '%s/v1alpha/iceconfig?key=%s'
    36. ICE_SERVER_API_KEY = os.environ.get('ICE_SERVER_API_KEY')
    37. HEADER_MESSAGE = os.environ.get('HEADER_MESSAGE')
    38. ICE_SERVER_URLS = [url for url in os.environ.get('ICE_SERVER_URLS', '').split(',') if url]
    39. # Dictionary keys in the collider instance info constant.
    40. WSS_INSTANCE_HOST_KEY = 'host_port_pair'
    41. WSS_INSTANCE_NAME_KEY = 'vm_name'
    42. WSS_INSTANCE_ZONE_KEY = 'zone'
    43. WSS_INSTANCES = [{
    44. WSS_INSTANCE_HOST_KEY: '192.168.101.64:8088',
    45. WSS_INSTANCE_NAME_KEY: 'wsserver-std',
    46. WSS_INSTANCE_ZONE_KEY: 'us-central1-a'
    47. },{
    48. WSS_INSTANCE_HOST_KEY: '192.168.101.64:8088',
    49. WSS_INSTANCE_NAME_KEY: 'wsserver-std-2',
    50. WSS_INSTANCE_ZONE_KEY: 'us-central1-f'
    51. }]
    52. WSS_HOST_PORT_PAIRS = [ins[WSS_INSTANCE_HOST_KEY] for ins in WSS_INSTANCES]
    53. # memcache key for the active collider host.
    54. WSS_HOST_ACTIVE_HOST_KEY = 'wss_host_active_host'
    55. # Dictionary keys in the collider probing result.
    56. WSS_HOST_IS_UP_KEY = 'is_up'
    57. WSS_HOST_STATUS_CODE_KEY = 'status_code'
    58. WSS_HOST_ERROR_MESSAGE_KEY = 'error_message'
    59. RESPONSE_ERROR = 'ERROR'
    60. RESPONSE_ROOM_FULL = 'FULL'
    61. RESPONSE_UNKNOWN_ROOM = 'UNKNOWN_ROOM'
    62. RESPONSE_UNKNOWN_CLIENT = 'UNKNOWN_CLIENT'
    63. RESPONSE_DUPLICATE_CLIENT = 'DUPLICATE_CLIENT'
    64. RESPONSE_SUCCESS = 'SUCCESS'
    65. RESPONSE_INVALID_REQUEST = 'INVALID_REQUEST'
    66. IS_DEV_SERVER = os.environ.get('APPLICATION_ID', '').startswith('dev')
    67. BIGQUERY_URL = 'https://www.googleapis.com/auth/bigquery'
    68. # Dataset used in production.
    69. BIGQUERY_DATASET_PROD = 'prod'
    70. # Dataset used when running locally.
    71. BIGQUERY_DATASET_LOCAL = 'dev'
    72. # BigQuery table within the dataset.
    73. BIGQUERY_TABLE = 'analytics'
     

    进入apprtc目录

    #编译

    cd /root/webrtc/apprtc

    sudo cnpm install

    sudo grunt build

  8. 测试启动

    sudo /root/webrtc/google_appengine/dev_appserver.py  --host=192.168.101.64 --port=8090 /root/webrtc/apprtc/out/app_engine --skip_sdk_update_check

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/爱喝兽奶帝天荒/article/detail/850927
推荐阅读
  

闽ICP备14008679号