几周来,我一直在尝试使用apprtc在原生android应用程序(https://github.com/njovy/AppRTCDemo
)和浏览器之间建立一个web会话。当使用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
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
的部署过程)从git下载了最新版本的apprtc
已安装的npm、nodejs和grunt
使用grunt build构建源代码
已下载、安装和配置对撞机(对撞机在RTC:8089上运行)
4.1我必须更改main.go in workspace/src/collidermain
发件人:var roomsrv=flag.string(“房间服务器”,“hxxps://appr.tc”,“房间服务器的来源”)
收件人:var roomsrv=flag.string(“房间服务器”,“hxxp://rtc”,“房间服务器的来源”)
4.2还将src/app_engine/constants.py中的ws_instance_host_key更改为colliders adresse rtc:8089
我安装了coturn并添加了一个turnserver.conf,看起来像
监听端口=3478
监听IP=192.168.178.20
用户=rtc:webrtc
证书=/home/rtc/work/src/collider/cert/cert.pem
pkey=/home/rtc/work/src/collider/cert/key.pem号
对撞机在192.168.178.20:8089(或RTC:8089)上运行,TurnServer在192.168.178.20:3478上运行。
turnserver.conf中定义的凭据:username=rtc,password=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
我能够在两个浏览器客户端之间建立连接(来自Collider Terminal的日志)
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的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 server address插入到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的url
导致错误?
我必须绕过它吗?
提前谢谢!
最佳答案
将它们全部设置为空字符串:
ICE_SERVER_BASE_URL = ''
ICE_SERVER_URL_TEMPLATE = ''
ICE_SERVER_API_KEY = ''
你设置柯林德网址了吗?
你的TurnServer应该使用OAuth配置。
检查所有日志:apprtc、chrome控制台日志、turnserver日志、collinder日志。更多细节。