PubNub webrtc 仅适用于本地网络
PubNub webrtc only working on local network
我之前问过一个关于这个的问题,但没有运气..
我在学习本教程 https://www.pubnub.com/blog/2014-10-21-building-a-webrtc-video-and-voice-chat-application/ 时遇到问题。
我编写了代码,它在本地网络上完美运行,但是当我尝试连接远程客户端(即不在同一网络上)时,代码不再运行。它只是在客户端视频应该显示的地方显示黑屏。
phone.receive(function(session){
session.connected(function(session){
$("#vid-box").append(session.video); //outputs black screen
});
session.ended(function(session) {alert("Call ended: "+session.number});
});
我什至联系过 PubNub,但他们无能为力。
有人有什么想法吗?
WebRTC双NAT哦不!
⚠️ TURN Server NOT PROVIDED ⚠️
确保您没有在 NAT 网络转发上。否则,您将需要 TURN servers
(未提供)。 TURN 服务器代理网络流量并允许受限的网络视频对话。大多数移动提供商都是基本的开放路由(非 NAT)。大多数企业防火墙至少有一个 NAT。
- TURN 流二进制视频。 NATed 网络需要但不是必需的。
- STUN 解析 IP 地址。 点对点发现。
- PUBNUB 发送 IP 地址。
STUN provides the IP Address. There is nothing in WebRTC to provide a means to exchange that IP Address between the connecting clients. This is where PubNub comes in.
WebRTC 资源和 SDK 链接
所以,我终于成功了。
我只是按照此处提到的教程将 Turn/Stun 服务器添加到 pubnub 调用函数:https://xirsys.com/pubnub-part-2/
非常感谢@PubNub 的建议。
function get_xirsys_servers() {
var servers;
$.ajax({
type: 'POST',
url: 'https://service.xirsys.com/getIceServers',
data: {
room: 'default',
application: 'default',
domain: 'www.thedomainyoucreated.com',
ident: 'yourxirsysident',
secret: 'secret-token-from-xirsys-dash',
},
success: function(res) {
res = JSON.parse(res);
if (!res.e) servers = res.d.iceServers;
},
async: false
});
return servers;
}
//Request to connect to Remote User
function makeCall( remoteId ){
if (!window.phone) alert("Login First!");
else if( !remoteId ) alert("The call id is missing or invalid!");
else phone.dial( remoteId, get_xirsys_servers() );
}
我之前问过一个关于这个的问题,但没有运气.. 我在学习本教程 https://www.pubnub.com/blog/2014-10-21-building-a-webrtc-video-and-voice-chat-application/ 时遇到问题。 我编写了代码,它在本地网络上完美运行,但是当我尝试连接远程客户端(即不在同一网络上)时,代码不再运行。它只是在客户端视频应该显示的地方显示黑屏。
phone.receive(function(session){
session.connected(function(session){
$("#vid-box").append(session.video); //outputs black screen
});
session.ended(function(session) {alert("Call ended: "+session.number});
});
我什至联系过 PubNub,但他们无能为力。 有人有什么想法吗?
WebRTC双NAT哦不!
⚠️ TURN Server NOT PROVIDED ⚠️
确保您没有在 NAT 网络转发上。否则,您将需要 TURN servers
(未提供)。 TURN 服务器代理网络流量并允许受限的网络视频对话。大多数移动提供商都是基本的开放路由(非 NAT)。大多数企业防火墙至少有一个 NAT。
- TURN 流二进制视频。 NATed 网络需要但不是必需的。
- STUN 解析 IP 地址。 点对点发现。
- PUBNUB 发送 IP 地址。
STUN provides the IP Address. There is nothing in WebRTC to provide a means to exchange that IP Address between the connecting clients. This is where PubNub comes in.
WebRTC 资源和 SDK 链接
所以,我终于成功了。 我只是按照此处提到的教程将 Turn/Stun 服务器添加到 pubnub 调用函数:https://xirsys.com/pubnub-part-2/ 非常感谢@PubNub 的建议。
function get_xirsys_servers() {
var servers;
$.ajax({
type: 'POST',
url: 'https://service.xirsys.com/getIceServers',
data: {
room: 'default',
application: 'default',
domain: 'www.thedomainyoucreated.com',
ident: 'yourxirsysident',
secret: 'secret-token-from-xirsys-dash',
},
success: function(res) {
res = JSON.parse(res);
if (!res.e) servers = res.d.iceServers;
},
async: false
});
return servers;
}
//Request to connect to Remote User
function makeCall( remoteId ){
if (!window.phone) alert("Login First!");
else if( !remoteId ) alert("The call id is missing or invalid!");
else phone.dial( remoteId, get_xirsys_servers() );
}