When two client simultaneously announce themselves to the signalling server, they will both create a Peer with { initiator: true } before sending the offer message to each other. As such, both parties will attempt to answer each other's offer and the second answer will result in an ERR_SET_REMOTE_DESCRIPTION. Thereafter, the connection closes and the when the reconnection takes place, both clients have { initiator: false }, causing a standstill as they wait for each other.
This issue is similar to glare, and simple-peer is unlikely to handle this issue in the foreseeable future based on previous discussion.
Approach
Generate a tiebreaker value glareToken for each webrtc connection object when a signal event occurs.
Include the tiebreaker value for signal messages.
When a client receives an offer message with a lower tiebreaker value, it is ignored.
Tiebreaker values are cleared on both sides of the webrtc connection when a successful connection is established.
Context
When two client simultaneously announce themselves to the signalling server, they will both create a
Peer
with{ initiator: true }
before sending theoffer
message to each other. As such, both parties will attempt to answer each other's offer and the second answer will result in anERR_SET_REMOTE_DESCRIPTION
. Thereafter, the connection closes and the when the reconnection takes place, both clients have{ initiator: false }
, causing a standstill as they wait for each other.This issue is similar to glare, and simple-peer is unlikely to handle this issue in the foreseeable future based on previous discussion.
Approach
glareToken
for each webrtc connection object when a signal event occurs.signal
messages.offer
message with a lower tiebreaker value, it is ignored.