当我尝试在两个对等方之间第二次连接时,会发生此错误。
P1 - Person 1, P2 - Person 2
它是这样的:
P1 emits "Looking for partner" ->
P2 emits "Looking for partner" ->
Server emits to P2 "Partner found" ->
P2 creating new Peer with initiator: true
P2 emits to Server "I am ready" ->
Server emits to P1 "P2 wants to connect" ->
P1 creating new Peer with initiator: false
P1 emits to Server "P2 is accepted"
Server emits to P2 "You are accepted" ->
And they can talk at this point
Then When P2 is closing conversation
P2 is doing peer.destroy();
P2 emits to Server "Let P1 know that I disconnected"
Server emits to P1 "P2 is off"
P1 is doing peer.destroy();
现在,当我想做完全相同的事情(P2 再次是发起者)时,我收到了这个错误。Server emits to P2 "You are accepted" ->
当我这样做时,它恰好发生在功能上:peer.signal(data.signal);
这就是它的样子peer._debug = console.log;
starting batched negotiation
start negotiation
signalingStateChange have-local-offer
createOffer success
iceStateChange (connection: new) (gathering: gathering)
started iceComplete timeout
iceStateChange (connection: new) (gathering: complete)
signal
iceStateChange (connection: checking) (gathering: complete)
signal()
on track
iceStateChange (connection: connected) (gathering: complete)
maybeReady pc true channel false
flushing sender queue []
negotiate
signalingStateChange stable
on channel open
maybeReady pc true channel true
connect local: 192.168.0.21:64575 remote: 192.168.0.21:64579
connect
destroy (error: undefined)
starting batched negotiation
start negotiation
signalingStateChange have-local-offer
createOffer success
iceStateChange (connection: new) (gathering: gathering)
started iceComplete timeout
iceStateChange (connection: new) (gathering: complete)
signal
iceStateChange (connection: checking) (gathering: complete)
Uncaught Error: cannot signal after peer is destroyed
代码可在此处获得: https://codeshare.io/5OjVNx用于正面 https://codeshare.io/2KlpWK用于背面