适用于appr.tc的原生Android应用

时间:2016-11-05 01:54:29

标签: android webrtc apprtcdemo apprtc openwebrtc

自从几个星期以来,我一直试图通过使用apprtc在本机Android应用程序(https://github.com/njovy/AppRTCDemo)和浏览器之间建立websession。当使用appr.tc作为room-server 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

Error-Screenshot

错误消息中提到的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
  2. 下载最新的apprtc版本   
  3. 已安装npm,nodejs和grunt
  4.   
  5. 使用grunt build构建源代码
  6.   
  7. 下载,安装并配置对撞机(对撞机在rtc:8089上运行)      
        
    • 4.1我必须在workspace / src / collidermain中更改main.go    from: var roomSrv = flag.String(" room-server"," hxxps://appr.tc"," the origin of the客房服务器")
         to: var roomSrv = flag.String(" room-server"," hxxp:// rtc","会议室服务器的来源& #34)
    •   
    • 4.2在src / app_engine / constants.py
    • 中将WS_INSTANCE_HOST_KEY更改为碰撞者adresse rtc:8089   
  8.   
  9. 我安装了CoTurn并添加了一个看起来像
    的turnserver.conf   监听端口= 3478
      听-IP = 192.168.178.20
      用户= RTC:的WebRTC
      证书= /家庭/ RTC /工作/ src目录/撞机/ CERT / cert.pem
      p键= /家庭/ RTC /工作/ SRC /撞机/ CERT / key.pem
  10.   

Collider在192.168.178.20:8089(或rtc:8089)上运行,而转向服务器在192.168.178.20:3478上运行。 在turnserver.conf中定义的凭据:Username = rtc,Password = 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 = [] out,评论了我的turnserver中的其他行并填写了我的凭据,在turnserver.conf中配置

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

Error Screenshot 2

但现在我无法再通过浏览器打开主机了。因此,我猜它可能完全错了。

  • 您是否知道如何使用原生应用程序建立会议?
  • 如何绕过可能的networktraversal.googleapis.com网址 导致错误?
  • 我是否必须绕过它?

提前致谢!

1 个答案:

答案 0 :(得分:0)

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

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

您设置了垃圾收集器网址吗? 并且您的Turnserver应该使用oauth config。 请查看以下所有日志:apprtc,chrome控制台日志,turnserver日志,collinder日志。以了解更多详细信息。