Receiving a media stream but won't show.

5,154 views
Skip to first unread message

met...@gmail.com

unread,
Dec 23, 2013, 7:59:20 PM12/23/13
to pee...@googlegroups.com
This problem only happens when connecting through the internet. When caller and callee are in the same LAN my code works. Everything seems to work fine at first but no remote video stream gets displayed.

Here are the logs of the callee (identical when both on LAN):

PeerJS: Socket open peer.js:1
PeerJS: Creating RTCPeerConnection. peer.js:1
PeerJS: Listening for ICE candidates. peer.js:1
PeerJS: Listening for `negotiationneeded` peer.js:1
PeerJS: Listening for data channel peer.js:1
PeerJS: Listening for remote stream peer.js:1
PeerJS: Setting remote description
RTCSessionDescription {sdp: "v=0
↵o=- 7187042667088147170 2 IN IP4 127.0.0.1
↵s…70 label:ATMg5EjcUtmet7QBmgrXmmVn1OUNKw8om5xVv0
↵", type: "offer"}
peer.js:1
12
PeerJS: Added ICE candidate for: vnxqllnq85g3c8fr peer.js:1
PeerJS: `negotiationneeded` triggered peer.js:1
PeerJS: onnegotiationneeded triggered when not stable. Is another connection being established? peer.js:1
PeerJS: Received remote stream peer.js:1
PeerJS: Receiving stream
MediaStream {onremovetrack: null, onaddtrack: null, onended: null, ended: false, id: "ATMg5EjcUtmet7QBmgrXmmVn1OUNKw8om5xV"…}
peer.js:1
PeerJS: Set remoteDescription: OFFER for: vnxqllnq85g3c8fr peer.js:1
PeerJS: Created answer. peer.js:1
PeerJS: Set localDescription: answer for: vnxqllnq85g3c8fr peer.js:1
6
PeerJS: Received ICE candidates for: vnxqllnq85g3c8fr



This is the code for the answering peer:



var answer = function(peer, onCall){
peer.on('call', function(call) {
navigator.getUserMedia(
{video: true, audio: true},
function(stream) {
call.answer(stream);
myVideoObject.src = window.URL.createObjectURL(
stream
);
myVideoObject.play();
},
function(err) {
console.log(
'Failed to get local stream',
err
);
call.answer();
});
call.on('stream', function(remoteStream) {
console.log(
'Received remoteStream',
remoteStream
);
inVideoObject.src = window.URL.createObjectURL(
remoteStream
);
inVideoObject.play();
});
// ... more error handlers and hangup code here
};



The calling peer uses similar code, this is how the peers get initiated on both ends:



peer = new Peer('{{appointment.uid}}',
{
host: 'control.vistacan.com',
port: 9000,
key: 'peerjs',
debug: 3,
config: { 'iceServers': [
{ 'url': 'stun:stun.l.google.com:19302' }
] }
});



Both caller and callee use latest versions of chrome, as I said it all works when both are in the same LAN. I am running my own peerjs service as such:


/usr/local/node-v0.10.6-linux-x64/lib/node_modules/peer/bin/peerjs -p 9000 --sslcert /path/to/my/cert --sslkey /path/to/my/key


Feel free to try it out (ssl only) at control.vistacan.com:9000 key: peerjs


What am I doing wrong?

Cheers,
Ivan

Ivan Metzlar

unread,
Dec 24, 2013, 3:36:03 PM12/24/13
to pee...@googlegroups.com
I just ran a test with the same code but this time using peerjs from the cloud with a developer API key. Still the same problem. Here is my client code: http://pastebin.com/JkXauuwt

I hope someone can help me out.

Cheers,
Ivan

code....@gmail.com

unread,
Feb 5, 2014, 11:10:26 AM2/5/14
to pee...@googlegroups.com
Hi

I am facing similair issue with peerjs:






I have developed a webrtc based video chat using peerjs. The solution is working fine but for some user facing problem to establish the call. I guess it is due to NAT and firewall issues.

Initially i used
var peer = new Peer({host: myserver.com], port: 9000, debug: true});

next i have added the stun part:

peer = new Peer(
{
host: 'myserver.com',
port: 9000,
debug: true,
config: { 'iceServers': [
{ 'url': 'stun:stun.l.google.com:19302' }
] }
});

But same issue. Some user can connect peer and use the service. some still not. did i made any mistake?

alex....@gmail.com

unread,
Feb 22, 2014, 6:16:33 PM2/22/14
to pee...@googlegroups.com
I have the exact same issue, the problem is that you need to fall back to a TURN server. Even after configuring TURN servers correctly, I still get the issues and I noticed the same peers having problems connecting on my app cannot connect with each other using any of the demo apps on the peerJS website, and also using the talky.io simpleWebRTC app, and some other simpleWebRTC based apps, not sure what is common with all these apps and how they configure TURN. The problematic peers successfully connect using vline.com, also built with webRTC. If anyone can help debug this issue that would be well appreciated. Thanks guys.

Srikanta Patanjali

unread,
May 3, 2014, 9:46:40 AM5/3/14
to pee...@googlegroups.com
Looks like i'm new into this queue. 

I have deployed the simple video chat using PeerJS at http://parallelthoughts.in/demo/webrtc. It works fine with 2 users in the same LAN/Wi-Fi network but the video doesn't get shown when users are on different network. The browser used is the latest Chrome version.

Would love to hear if any one has any work around to this problem. Facing the same problem with SimpleWebRTC as well !

Thanks!

Srikanta Patanjali

unread,
May 3, 2014, 2:03:00 PM5/3/14
to pee...@googlegroups.com
So I was able to find the solution for this common problem. Here it goes :

1. As we try to share the data between different networks, most of the times its the NAT or a firewall which causes this problem. So its absolutely necessary to have multiple TURN server along with the the usual STUN server.

2. I was able to find a list of working TURN and STUN server addr which we can use it for demo applications. Check this link > https://gist.github.com/yetithefoot/7592580


Cheers,
Srikanta

Michelle Bu

unread,
May 3, 2014, 2:27:21 PM5/3/14
to Srikanta Patanjali, peerjs
Thanks for sharing!
Michelle

websnake.s...@gmail.com

unread,
May 29, 2014, 12:23:00 PM5/29/14
to pee...@googlegroups.com
Hi Srikanta,

it's an interesting solution and if it's possible I have two questions for you:

1. In your link http://parallelthoughts.in/demo/webrtc the solution was implemented?

2. How can I add the list of working TURN and STUN in the basic code?

Thank you in advance

Srikanta Patanjali

unread,
May 29, 2014, 12:49:15 PM5/29/14
to websnake.s...@gmail.com, pee...@googlegroups.com
Hi Websnake,

Yes, the demo contains the fallback address of TURN servers. 

Here is the example by which you can do this:

    var peer = new Peer({ key: 'oz9b3ni30qtcsor', debug: 3, config: {'iceServers': [
                { url: 'stun:stun.l.google.com:19302' },
                { url: 'turn:numb.viagenie.ca:3478', credential: 'muazkh', username:'web...@live.com' },
                { url: 'turn:numb.viagenie.ca', credential: 'muazkh', username:'web...@live.com' },
                { url: 'turn:192.158.29.39:3478?transport=udp', credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=', username:'28224511:1379330808' },
                { url: 'turn:192.158.29.39:3478?transport=tcp', credential: 'JZEOEt2V3Qb0y27GRntt2u2PAYA=', username:'28224511:1379330808' }
            ]}});

Also you can take a look at the source for more details > https://bitbucket.org/psrikanta/webrtc


Regards,
Srikanta

websnake.s...@gmail.com

unread,
May 29, 2014, 1:00:06 PM5/29/14
to pee...@googlegroups.com, websnake.s...@gmail.com
Many many thanks Srikanta, perfect!
Reply all
Reply to author
Forward
0 new messages