Thanks for this amazing library. I was just trying to connect two peers and send some data.On chrome It works just fine but on firefox 59.0.2 It breaks with the following error,
TypeError: Argument 1 of RTCPeerConnection.getStats does not implement interface MediaStreamTrack
Can you make a demo on jsfiddle or similar service? Or at very least reduces test case?
This shouldn't happen in modern versions of Firefox under normal circumstances.
Sure. I'm not a JS coder by day.Please forgive mistakes if any :grin: I've put together the relevant parts inside a gist. It was originally written inside a vue component.
If you look at source code:
https://github.com/feross/simple-peer/blob/872b2c41f708edd94c2f37642c14b58a1a8d2c78/index.js#L578-L589
It can be reduced to this simple test:
> p = new RTCPeerConnection
RTCPeerConnection { localDescription: null, currentLocalDescription: null, pendingLocalDescription: null, remoteDescription: null, currentRemoteDescription: null, pendingRemoteDescription: null, signalingState: "stable", canTrickleIceCandidates: null, iceGatheringState: "new", iceConnectionState: "new" }
> p.getStats.length
0
> p.getStats().then(console.log)
Promise { <state>: "pending" }
RTCStatsReport { size: 0 }
It doesn't fail for me in Firefox and shouldn't fail for you too. Error from the first comment indicated that this check fails for some reason.
Are you using latest version of simple-peer? Did you include https://github.com/webrtc/adapter on your page (if you did - it is not necessary for this library)?
Thanks @nazar-pc I guess including https://github.com/webrtc/adapter was the problem. I got it working now I'm not sure what went wrong.
It seems that @nazar-pc is right,
I also use simple-peer, and when I tried to include adpater.js, the connected event was not fired in firefox.
after I removed adapter.js, things are working again.
Most helpful comment
Thanks @nazar-pc I guess including
https://github.com/webrtc/adapterwas the problem. I got it working now I'm not sure what went wrong.