zoukankan      html  css  js  c++  java
  • WebRTC之搭建coturn服务遇到的问题

    准备工作
    准备一台云服务器,没有的小伙伴可以去撸谷歌云300刀
    我这里是Ubuntu18.04

    clone coturn代码
    git clone https://github.com/coturn/coturn.git
    1
    不懂git的请自行百度

    编译coturn
    cd coturn
    ./configure --prefix=/usr/local/coturn
    1
    2
    编译后的文件目录为/usr/local/coturn

    错误1
    install is /usr/bin/install
    pkill is /usr/bin/pkill
    sqlite3 is /usr/bin/sqlite3
    Use TMP dir /var/tmp
    Compiler: cc
    Library option -lsocket cannot be used
    Library option -lrt cannot be used
    Library option -lwldap32 cannot be used
    Library option -lwldap64 cannot be used
    Library option -lintl cannot be used
    Library option -lnsl cannot be used
    Sockets code is fine: sin_len field present
    pthread barriers not found
    Ignore IP_RECVERR
    Library option -lcrypto cannot be used
    ERROR: OpenSSL Crypto development libraries are not installed properly in required location.
    Abort.
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    需要安装相关的依赖
    Ubuntu执行

    apt install libssl-dev
    1
    Centos执行

    yum install openssl-devel
    1
    然后再次运行

    ./configure --prefix=/usr/local/coturn
    1
    官方回答:https://github.com/coturn/coturn/issues/122

    错误2
    Libevent2 development is not installed properly
    ERROR: Libevent2 development libraries are not installed properly in required location.
    ERROR: may be you have just too old libevent tool - then you have to upgrade it.
    See the INSTALL file.
    Abort.
    1
    2
    3
    4
    5
    执行以下代码

    apt-get install libevent-dev
    1
    然后再次运行

    ./configure --prefix=/usr/local/coturn
    1
    查看是否生成Makefile文件,如果有代表成功

    ll Makefile
    1
    执行make命令 -j代表是用多少线程执行,一般双核就写4 4核就写8

    make -j 16
    sudo make install
    安装好后会看到如下图


    配置coturn

    进入刚刚的目录/usr/local/coturn ,编辑文件

    cd /usr/local/coturn
    vim etc/turnserver.conf.default
    按照上面的截图依次填入信息,除了云主机的IP外,其他的都可以随便设置改完后保存

    如果出现以下错误

    ERROR: Empty cli-password, and so telnet cli interface is disabled! Please set a non empty cli-password!错误
    需要在vim etc/turnserver.conf.default 添加

    cli-password=youpasswd
    对应的github 官方issue
    https://github.com/coturn/coturn/issues/361

    配置证书
    openssl req -x509 -newkey rsa:2048 -keyout /etc/turn_server_pkey.pem -out /etc/turn_server_cert.pem -days 99999 -nodes
    vim etc/turnserver.conf.default
    把以下的注释取消掉,注意证书的路径根据自己生成的路径填写
    cert=/etc/turn_server_cert.pem
    pkey=/etc/turn_server_pkey.pem
    最小端口和最大端口
    这个是限制端口范围的,最好是设置下,并且阿里云安全组和防火墙也要添加对应规则

    vim etc/turnserver.conf.default
    min-port=49152
    max-port=65535
    启动turnserver
    这里怕有小白所以写的全部路径,其实相对路径就可以了,不懂的直接复制这句话

    /usr/local/coturn/bin/turnserver -o -a -f -c /usr/local/coturn/etc/turnserver.conf.defaul -r Chengdu
    注意!
    如果是云主机的话需要打开对应的端口,如阿里云需要在安全组添加规则3478,UDP和TCP,需要同时开启并且如果云服务开启了防火墙需要添加防火墙规则,我这里是Ubuntu,执行以下命令

    sudo ufw allow 3478
    最好telnet一下看下端口是否是通的。

    telnet 云主机ip 3478
    如果是通的打开以下地址检测
    https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/

     


    WebRTC使用trun服务
    var configuration = { iceServers: [
    {urls: "stun:youip:5060"},
    {
    urls: "turn:youip:5060",
    username: 'you user',
    credential: 'you passwd',
    }];
    };

    var pc = new RTCPeerConnection(configuration);
    WebRTC参考文章:https://developer.mozilla.org/zh-CN/docs/Web/API/RTCConfiguration

    学习时的痛苦是暂时的 未学到的痛苦是终生的
  • 相关阅读:
    edgedb 内部pg 数据存储的探索 (四) 源码编译
    edgedb 内部pg 数据存储的探索 (二) 创建数据库命令说明
    edgedb 内部pg 数据存储的探索 (三) 源码包setup.py 文件
    python 集成cython && push 测试pip 仓库
    python 集成cython 简单测试
    click python cli 开发包
    转载一篇阿里云Terraform 开发指南
    zabbix 4.2 支持 timescledb 了
    edgedb 内部pg 数据存储的探索 (一)基本环境搭建
    Podman and Buildah for Docker users
  • 原文地址:https://www.cnblogs.com/grimm/p/14785489.html
Copyright © 2011-2022 走看看