Simple-peer: Error when connecting through Firefox

Created on 26 Apr 2018  路  5Comments  路  Source: feross/simple-peer

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

question

Most helpful comment

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.

All 5 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jimmywarting picture jimmywarting  路  3Comments

onel picture onel  路  5Comments

contra picture contra  路  6Comments

alexmarion picture alexmarion  路  4Comments

saagarbethi picture saagarbethi  路  4Comments