Video Chat

143 views
Skip to first unread message

Alex Lovsky

unread,
Oct 10, 2019, 8:08:43 AM10/10/19
to PeerJS
Good day. I'm trying to arrange video connection (video chat) between to remote users using peer.js.
When I test peer connection + peer.call on my computers (different) - everything working good. In each browser
// Start Script
 conn=peer.connect(id);
 conn
.on('open',function(){console.log("Connection open");});
 
+
 
const call=peer.call(conn.peer,localMediaStream);
 call
.on('stream',function(call){console.log("Start call");const video=document.querySelector('.remote_video');video.srcObject=call;});
- work good
// Received Script
 peer.on('connection',function(c){console.log("Connected");});
 
+
 peer
.on('call',function(call){console.log("Start call");call.answer(localMediaStream);call.on('stream', function(stream){console.log("Start call");const video=document.querySelector('.remote_video');video.srcObject=stream;});});
- work good

But when I test same scripts on computers in different countries then:

// Start Connection
 conn=peer.connect(id);
- (Start Script) - work good
 peer.on('connection',function(c){console.log("Connected");});
- (Received Script) - work good
BUT
 conn.on('open',function(){console.log("Connection open");});
- (Start Script) - not work good -> RTCDataChannel->readyState->"connecting" - not change to "open"
// Start Call
 const call=peer.call(conn.peer,localMediaStream);
 call
.on('stream',function(call){console.log("Start call");const video=document.querySelector('.remote_video');video.srcObject=call;});
- (Start Script)
 peer.on('call',function(call){console.log("Start call");call.answer(localMediaStream);call.on('stream', function(stream){console.log("Start call");const video=document.querySelector('.remote_video');video.srcObject=stream;});});
- (Received Script)
everything seems to work - all scripts receive steams, but but nothing work (video not shown)

Are there any ways to solve this problem?
Reply all
Reply to author
Forward
0 new messages