几周以来,我一直在尝试使用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/contents.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')
}
到目前为止我做了什么?(这几乎是近似https://github.com/webrtc/apprtc#deployment
的部署过程(
- 从git下载apprtc的最新版本
- 已安装npm、nodejs和grunt
- 使用grunt构建构建资源
- 下载、安装和配置的对撞机(对撞机运行在rtc:8089上(
- 4.1我不得不在workspace/src/coldermain中更改我的main.go
来自:var roomSrv=标志。字符串("房间服务器","hxxps://appr.tc","房间服务器的起源"(
到:var roomSrv=标志。字符串("房间服务器","hxxp://rtc","房间服务器的来源"(- 4.2还在src/app_engine/contents.py中将WS_INSTANCE_HOST_KEY更改为collapsers地址rtc:8089
- 我安装了CoTurn并添加了一个turnserver.conf,看起来像
侦听端口=3478
侦听ip=192.168.178.20
user=rtc:webrtc
cert=/home/rtc/work/src/colder/cert/cert.pem
pkey=/home/rtc/work/src/colder/cert/key.pem
Collider在192.168.178.20:8089(或rtc:8089(上运行,turnserver在192.168.178-20:3478上运行。turnserver.conf中定义的凭据:用户名=rtc,密码=webrtc
设置完成后,我将requestIceServers方法添加到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 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的IP和我的凭据,在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
但是仍然抛出相同的错误。
由于这也不起作用,我尝试将turn服务器地址插入ICE_server_BASE_URL(仍在常量.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导致错误的原因
- 我必须绕过它吗
提前感谢!
将它们全部设置为空字符串:
ICE_SERVER_BASE_URL = ''
ICE_SERVER_URL_TEMPLATE = ''
ICE_SERVER_API_KEY = ''
你设置了collinder url吗?您的turnserver应该使用oauth配置。检查所有日志:apprtc、chrome控制台日志、turnserver日志、collinder日志。。了解更多详细信息。