关键词:原版更新到合成项目,webrtc一次连通关键点分析
一、原版更新到合成项目
昨天在原版上解决了连接不稳定问题(即头几次连不上,之后能连上),今天要把原版代码更新到现有项目上。
1.1 更新合成项目上index.html文件
并把最新的RTCMultiConnection.min.js放上去
1.2 更新server.js文件
我是全部替换,只把端口9002---->9001
1.3 更新了config.json文件,多加了一行如下:
"autoRebootServerOnFailure": "true"
1.3 Gruntfile.js文件进行了更新
1.4 Scalable-Broadcast.js文件更新
1.5 1.5 Signaling-Server.js文件更新
1)更新rmc3.js-------它所在的地址如下:
https://webrtcexperiment-webrtc.netdna-ssl.com/rmc3.js
2) 更新了rmc3.min.js-----它所在的官网地址如下:
https://cdn.webrtc-experiment.com/rmc3.min.js
3)更新了rmc3.fbr.js,地址如下:
https://webrtcexperiment-webrtc.netdna-ssl.com/rmc3.fbr.js
4)更新了rmc3.fbr.min.js,地址如下:
https://webrtcexperiment-webrtc.netdna-ssl.com/rmc3.fbr.min.js
二、代码调试
现在测试一次连通了,但为什么之前连几次才连通,现在能一次连通,经过分析,原因如下:
原来的代码中,传递信令的服务器只有3个ice服务器。如下:
var IceServersHandler = (function() {
function getIceServers(connection) {
var iceServers = [];
iceServers.push(getSTUNObj('stun:stun.l.google.com:19302'));
iceServers.push(getTURNObj('turn:webrtcweb.com:80', 'muazkh','muazkh'));
iceServers.push(getTURNObj('turn:webrtcweb.com:443', 'muazkh','muazkh'));
if (window.RMCExternalIceServers) {
iceServers =iceServers.concat(getExtenralIceFormatted());
} else if (typeofwindow.getExternalIceServers !== 'undefined' &&window.getExternalIceServers == true) {
connection.iceServers =iceServers;
window.iceServersLoadCallback =function() {
connection.iceServers = connection.iceServers.concat(getExtenralIceFormatted());
};
}
return iceServers;
}
return {
getIceServers: getIceServers
};
})();
而官网更新的代码中,服务器变成了9个ice服务器,所以连接成功率大大增加了。更新的代码如下:在RTCMultiConnection.js里面
varIceServersHandler = (function() {
function getIceServers(connection) {
var iceServers = [];
iceServers.push(getSTUNObj('stun:stun.l.google.com:19302'));
iceServers.push(getTURNObj('stun:webrtcweb.com:7788', 'muazkh','muazkh')); // coTURN
iceServers.push(getTURNObj('turn:webrtcweb.com:7788', 'muazkh','muazkh')); // coTURN
iceServers.push(getTURNObj('turn:webrtcweb.com:8877', 'muazkh','muazkh')); // coTURN
iceServers.push(getTURNObj('turns:webrtcweb.com:7788', 'muazkh','muazkh')); // coTURN
iceServers.push(getTURNObj('turns:webrtcweb.com:8877', 'muazkh','muazkh')); // coTURN
// iceServers.push(getTURNObj('turn:webrtcweb.com:3344','muazkh', 'muazkh')); // resiprocate
//iceServers.push(getTURNObj('turn:webrtcweb.com:4433', 'muazkh', 'muazkh')); //resiprocate
iceServers.push(getTURNObj('stun:webrtcweb.com:4455', 'muazkh','muazkh')); // restund
iceServers.push(getTURNObj('turn:webrtcweb.com:4455', 'muazkh','muazkh')); // restund
iceServers.push(getTURNObj('turn:webrtcweb.com:5544?transport=tcp','muazkh', 'muazkh')); // restund
if (window.RMCExternalIceServers) {
iceServers =iceServers.concat(getExtenralIceFormatted());
} else if (typeofwindow.getExternalIceServers !== 'undefined' &&window.getExternalIceServers == true) {
connection.iceServers =iceServers;
window.iceServersLoadCallback =function() {
connection.iceServers =connection.iceServers.concat(getExtenralIceFormatted());
};
}
return iceServers;
}
return {
getIceServers: getIceServers
};
})();
三、今天加了几个webrtc群,下一步是做IOS-webrtc的研究了,加油!
注:做技术不能闭门造车,要走出去,与人切磋交流才能提高自己,加油!
2016年11月30日星期三