簡體   English   中英

錯誤:對等方被銷毀后無法發出信號 - 簡單對等方

[英]Error: cannot signal after peer is destroyed - simple-peer

當我嘗試在兩個對等方之間進行第二次連接時,會發生此錯誤。

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;樣子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 for Front https://codeshare.io/2KlpWK for Back

好吧,結果我的代碼完全是垃圾,不應該這樣做! 我正在學習一些糟糕的教程。 這里的問題是信號在不斷循環中以一些錯誤結束,不知何故它像這樣工作,但你不能在不讓應用程序崩潰的情況下破壞對等點。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM