Simple-peer: Infinite loop sending renegotiate: true

Created on 2 Oct 2018  路  5Comments  路  Source: feross/simple-peer

I think this is more a question than an actual issue.
In the strange case where both peers are created with initiator: false, they will get in the loop of sending to each other a signal with {renegotiate: true}.

My question is: could/should simple peer handle this case or should it fall down to the app?
Thanks.

question

All 5 comments

Well, I believe it is application responsibility to make sure 2 peer have the opposite values of initiator option.
There are multiple ways this can be achieved, but they depend on specific needs of the particular application. Really not sure it is worth implementing in simple-peer itself.

A connection can't be established unless one peer is an initiator.

As for preventing an infinite loop, it should be an easy fix (non-initiators should ignore the {renegotiate: true} message. Will PR.

Yeah, I was thinking the same. The app should make sure the peers are created correctly.
Thanks for the PR.

hi, i am trying to develop a video chat application using react js and node
i have used simple-peer npm package , but the problem is when i try to signal an incoming signal it is causing a loop .
here is my code,

const addPeer = (data, stream) => {
console.log('add')

const peer = new Peer({
  initiator: false,
  trickle: false,
  stream
});

peer.on('signal', signal => {
  console.log('again')
  socket.emit("make-answer", {
    signal,
    user: user,
    to: data.senderSocket
  });
});


peer.signal(data.signal);
return peer;

};

when peer.signal fired then peer.on handler runs twice
can any one help?

Same behaviour noticed as above. When the non-initiator peer is signalled using peer.signal, the peer.on("signal" handler is executing twice.
Also I noticed the two signals emitted by that handler are different. One has {renegotiate: true} while the other has {type: "answer", sdp: "..."}
Anyone knows what's going wrong, or is this expected?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dnish picture dnish  路  5Comments

mullerivan picture mullerivan  路  4Comments

feross picture feross  路  4Comments

mmorainville picture mmorainville  路  4Comments

olgeorge picture olgeorge  路  5Comments