3

几周以来,我一直在尝试使用 apprtc 在原生 android 应用程序 ( https://github.com/njovy/AppRTCDemo) 和浏览器之间建立网络会话。该应用程序在使用 appr.tc 作为房间服务器 url 时运行良好。我已经在 Ubuntu 上设置了 apprtc 项目,并且能够在 Ubuntu 机器上的浏览器和我的移动设备的浏览器之间创建一个会议。但是当我尝试在 ubuntu 上的浏览​​器和应用程序之间建立连接时,我总是收到以下错误:

Room IO error: java.io.IOException:
Non-200 response when requesting 
TURN server from https://
networktraversal.googleapis.com/
v1alpha/iceconfig?key=none : HTTP/
1.1 400 Bad Request

错误截图

错误消息中提到的 URL 定义在 src/app_engine/constants.py ( https://github.com/webrtc/apprtc/blob/master/src/app_engine/constants.py) 中。但我不知道该怎么办

# TODO(jansson): Remove once AppRTCDemo on iOS supports ICE_SERVER.
TURN_BASE_URL = 'https://computeengineondemand.appspot.com'
TURN_URL_TEMPLATE = '%s/turn?username=%s&key=%s'
CEOD_KEY = '4080218913'

ICE_SERVER_BASE_URL = 'https://networktraversal.googleapis.com'
ICE_SERVER_URL_TEMPLATE = '%s/v1alpha/iceconfig?key=%s'
ICE_SERVER_API_KEY = os.environ.get('ICE_SERVER_API_KEY')

CALLSTATS_PARAMS = {
  'appId': os.environ.get('CALLSTATS_APP_ID'),
  'appSecret': os.environ.get('CALLSTATS_APP_SECRET')
}

那么到目前为止我做了什么?(差不多就是 apprtc 的部署过程https://github.com/webrtc/apprtc#deployment

  1. 从 git 下载最新版本的 apprtc
  2. 安装了 npm、nodejs 和 grunt
  3. 使用 grunt build 构建源代码
  4. 下载、安装和配置碰撞器(碰撞器在 rtc:8089 上运行)
    • 4.1 我不得不将workspace/src/collidermain中的main.go
      从: var roomSrv = flag.String("room-server", "hxxps://appr.tc", "The origin of the room server")
      更改为: var roomSrv = flag.String("room-server", "hxxp://rtc", "房间服务器的来源")
    • 4.2 还将 src/app_engine/constants.py 中的 WS_INSTANCE_HOST_KEY 更改为对撞机地址 rtc:8089
  5. 我安装了 CoTurn 并添加了一个 turnserver.conf,看起来像 listener
    -port=3478 listener
    -ip=192.168.178.20
    user=rtc:webrtc
    cert=/home/rtc/work/src/collider/cert/cert.pem
    pkey=/主页/rtc/work/src/collider/cert/key.pem

Collider 运行在 192.168.178.20:8089(或 rtc:8089)上,turnserver 运行在 192.168.178.20:3478 上。turnserver.conf 中定义的凭据:用户名 = rtc,密码 = webrtc

设置后,我将 requestIceServers-Method 添加到 src/web_app/js/util.js ( https://github.com/webrtc/apprtc/blob/master/src/web_app/js/util.js)

function requestIceServers(iceServerRequestUrl, iceTransports) {
  return new Promise(function(resolve, reject) {
    var servers = [{
        credential: "webrtc",
        username: "rtc",
        urls: [
          "turn:192.168.178.20:3478?transport=udp",
          "turn:192.168.178.20:3478?transport=tcp"
        ]
    }];
    resolve(servers);
  });
}

并注释掉标准方法:

//function requestIceServers(iceServerRequestUrl, iceTransports) {
  //return new Promise(function(resolve, reject) {
    //sendAsyncUrlRequest('POST', iceServerRequestUrl).then(function(response) {
      //var iceServerRequestResponse = parseJSON(response);
      //if (!iceServerRequestResponse) {
        //reject(Error('Error parsing response JSON: ' + response));
        //return;
      //}
      //if (iceTransports !== '') {
        //filterIceServersUrls(iceServerRequestResponse, iceTransports);
      //}
      //trace('Retrieved ICE server information.');
      //resolve(iceServerRequestResponse.iceServers);
    //}).catch(function(error) {
      //reject(Error('ICE server request error: ' + error.message));
      //return;
    //});
  //});
//}

当我现在启动我的 GAE 时,我的转向服务器和对撞机

python ~/google_appengine/dev_appserver.py ~/google_projects/apprtc-master/out/app_engine --host=0.0.0.0
sudo turnserver -a -r 192.168.178.20
$GOPATH/bin/collidermain -port=8089 -tls=false

我能够在两个浏览器客户端之间建立连接(来自对撞机终端的日志)

rtc@rtc:~$ $GOPATH/bin/collidermain -port=8089 -tls=false
2016/11/05 00:07:32 Starting collider: tls = false, port = 8089, room-server=http://rtc
2016/11/05 00:10:24 Created room stackoverflow
2016/11/05 00:10:24 Added client 97869213 to room stackoverflow
2016/11/05 00:10:24 Client 97869213 registered in room stackoverflow
2016/11/05 00:10:57 Added client 96368166 to room stackoverflow
2016/11/05 00:10:57 Client 96368166 registered in room stackoverflow
2016/11/05 00:10:57 Sent queued messages from 97869213 to 96368166
2016/11/05 00:11:09 Deregistered client 96368166 from room stackoverflow
2016/11/05 00:11:09 Removed client 96368166 from room stackoverflow
2016/11/05 00:11:19 Removing client 96368166 from room stackoverflow due to timeout

当我现在尝试通过本机应用程序连接时,我总是收到上述错误。

经过调查,我在 git 上找到了以下链接,但对我没有太大帮助:https://github.com/webrtc/apprtc/issues/366

所以我决定使用 constants.py ( https://github.com/webrtc/apprtc/blob/master/src/app_engine/constants.py) 并找到一个可以覆盖 Turn/Stun 服务器的地方

# Turn/Stun server override. This allows AppRTC to connect to turn servers
# directly rather than retrieving them from an ICE server provider.
TURN_SERVER_OVERRIDE = []
# Enable by uncomment below and comment out above, then specify turn and stun
# servers below.
#TURN_SERVER_OVERRIDE = [
#  {
#    "urls": [
#      "turn:192.168.178.20:3478?transport=udp",
#      "turn:192.168.178.20:3478?transport=tcp"
#    ],
#    "username": "rtc",
#    "credential": "webrtc"
#  },
#  {
#    "urls": [
#      "stun:stun.l.google.com:19305"
#    ]
#  }
#]

所以我注释掉了 TURN_SERVER_OVERRIDE = []

GAE 认识到应用程序有一个新的请求。它记录

INFO     2016-11-05 00:06:31,649 apprtc.py:408] Added client 50600142 in room stackoverflow, retries = 0
INFO     2016-11-05 00:06:31,650 apprtc.py:92] Applying media constraints: {'video': True, 'audio': True}
WARNING  2016-11-05 00:06:31,653 apprtc.py:136] Invalid or no value returned from memcache, using fallback: null
INFO     2016-11-05 00:06:31,653 apprtc.py:551] User 50600142 joined room stackoverflow
INFO     2016-11-05 00:06:31,653 apprtc.py:552] Room stackoverflow has state ['50600142']
INFO     2016-11-05 00:06:31,658 module.py:788] default: "POST /join/stackoverflow?wstls=false HTTP/1.1" 200 1175

但仍然抛出同样的错误。

由于这也不起作用,我尝试将转服务器地址插入 ICE_SERVER_BASE_URL(仍在 constants.py 中)

ICE_SERVER_BASE_URL = 'https://networktraversal.googleapis.com'
ICE_SERVER_URL_TEMPLATE = '%s/v1alpha/iceconfig?key=%s'
ICE_SERVER_API_KEY = os.environ.get('ICE_SERVER_API_KEY')

变成

ICE_SERVER_BASE_URL = '192.168.178.20:3478'
ICE_SERVER_URL_TEMPLATE = ''
ICE_SERVER_API_KEY = os.environ.get('ICE_SERVER_API_KEY')

这将错误更改为:

Connection error
Non-200 response to POST to URL:
http://rtc:8080/join/stackoverflow=wstls=false : HTTP/1.1 500 Internal 
Server Error

错误截图 2

但现在我不再能够从浏览器打开主机。因此,我想这可能是完全错误的。

  • 您知道如何使用本机应用程序建立会议吗?
  • 如何绕过可能导致错误的 networktraversal.googleapis.com URL?
  • 我必须绕过它吗?

提前致谢!

4

1 回答 1

0

将它们全部设置为空字符串:

ICE_SERVER_BASE_URL = ''
ICE_SERVER_URL_TEMPLATE = ''
ICE_SERVER_API_KEY = ''

你设置了collinder url吗?并且您的转向服务器应该使用 oauth 配置。检查以下所有日志:apprtc、chrome 控制台日志、turnserver 日志、collinder 日志.. 以获取更多详细信息。

于 2019-04-09T05:53:31.307 回答