admin管理员组文章数量:1425717
Ive asked a question about this before but without any luck.. Im having problems following this tutorial / . Ive written the code and it works flawlessly on local network, but when i try to connect with a remote client(i.e. not on the same network) the code doesnt work anymore. It just shows a black screen where the video from the client should be.
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});
});
Ive even contacted PubNub but they were unable to help. Anyone has any ideas?
Ive asked a question about this before but without any luck.. Im having problems following this tutorial https://www.pubnub./blog/2014-10-21-building-a-webrtc-video-and-voice-chat-application/ . Ive written the code and it works flawlessly on local network, but when i try to connect with a remote client(i.e. not on the same network) the code doesnt work anymore. It just shows a black screen where the video from the client should be.
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});
});
Ive even contacted PubNub but they were unable to help. Anyone has any ideas?
Share Improve this question edited Jul 25, 2016 at 18:13 Craig Conover 4,7381 gold badge40 silver badges59 bronze badges asked Jul 25, 2016 at 16:30 Shanzid ShaihamShanzid Shaiham 691 gold badge3 silver badges15 bronze badges2 Answers
Reset to default 7WebRTC Double NAT Oh no!
⚠️ TURN Server NOT PROVIDED ⚠️
Make sure you are not on NAT network forwarding. Otherwise you'll need TURN servers
(not provided). TURN Servers broker network traffic and allow constrained network video conversations. Most mobile providers are basic open routing (non-NAT). Most corporate firewalls have at least one NAT.
- TURN Streams BINARY VIDEO. Needed for NATed networks but not required.
- STUN Resolves IP Address. Peer to Peer discovery.
- PUBNUB Sends IP Address.
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 es in.
WebRTC Resources and SDK Links
- Download: ZIP Download WebRTC SDK
- GitHub: GitHub Repository for WebRTC SDK
- Documentation: GitHub WebRTC Documentation
- Video: What is WebRTC Video Introduction
- Demo: WebRTC Live Calling App Demo
So, iv'e finally managed to make it work. i simply added Turn/Stun servers to the pubnub call function, following the tutorial mentioned here: https://xirsys./pubnub-part-2/ Thanks alot @PubNub for your suggestion.
function get_xirsys_servers() {
var servers;
$.ajax({
type: 'POST',
url: 'https://service.xirsys./getIceServers',
data: {
room: 'default',
application: 'default',
domain: 'www.thedomainyoucreated.',
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() );
}
本文标签: javascriptPubNub webrtc only working on local networkStack Overflow
版权声明:本文标题:javascript - PubNub webrtc only working on local network - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745392746a2656673.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论