socketio / socket.io-p2p

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`trickle = true` causes issues when multiple signals are received

hharnisc opened this issue · comments

The trickle setting to true enables trickle ICE which can send multiple signal events if your local network is configured in a certain way (say your socket.io-p2p server is being served from local host for instance).

When multiple signal events are received an incomplete offer is sent (offer.sdp), because only the first offer is accepted.

https://github.com/socketio/socket.io-p2p/blob/master/index.js#L74

And this causes P2P connections to fail because they don't know how to contact the peer.

The trickle setting is set in 2 places

https://github.com/socketio/socket.io-p2p/blob/master/index.js#L55
https://github.com/socketio/socket.io-p2p/blob/master/index.js#L83

Setting these to false fixed the issue for me. Happy to submit a PR for this if you like, it's only a couple lines of code.

Yes a PR would be awesome!
Setting the peerOpts in two places is not very DRY either and I have had a mind to refactor that so if happen to hover that up at the same time it would great!