【问题标题】:Error: cannot signal after peer is destroyed - simple-peer错误:对等体被破坏后无法发出信号 - 简单对等体
【发布时间】:2021-02-03 19:07:12
【问题描述】:

当我尝试在两个对等方之间第二次连接时,我发生了这个错误。

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 返回

【问题讨论】:

    标签: javascript node.js webrtc peer simple-peer


    【解决方案1】:

    好的,原来我的代码完全是垃圾,不应该这样做!我正在关注一些糟糕的教程。这里的问题是信号在不断循环中以一些错误结束,不知何故它像这样工作,但你不能在不让应用程序崩溃的情况下破坏对等点。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多