feross / simple-peer

📡 Simple WebRTC video, voice, and data channels
MIT License
7.44k stars 975 forks source link

Failed to execute 'setRemoteDescription' on 'RTCPeerConnection' #898

Closed abhi-dasgupta closed 2 years ago

abhi-dasgupta commented 2 years ago

What version of this package are you using? 9.11.1

What operating system, Node.js, and npm version? win 10, node 16, npm 8

What happened? getting "Uncaught DOMException: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': Failed to set remote answer sdp: Called in wrong state: stable" error

Offer Logs

starting batched negotiation
index.js:407 start negotiation
index.js:947 signalingStateChange have-local-offer
index.js:627 createOffer success
index.js:708 iceStateChange (connection: new) (gathering: gathering)
index.js:596 started iceComplete timeout
index.js:708 iceStateChange (connection: new) (gathering: complete)
index.js:619 signal
AppContext.js:151 --> sending offer
AppContext.js:152 --> OFFER {type: 'offer', sdp: 'v=0\r\no=- 5999517895916958975 2 IN IP4 127.0.0.1\r\ns…:2\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n'}
index.js:708 iceStateChange (connection: checking) (gathering: complete)
AppContext.js:165 --> answer received
AppContext.js:166 --> ANSWER {type: 'answer', sdp: 'v=0\r\no=- 5086403341498641310 2 IN IP4 127.0.0.1\r\ns…:2\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n'}
index.js:192 signal()
AppContext.js:165 --> answer received
AppContext.js:166 --> ANSWER {type: 'answer', sdp: 'v=0\r\no=- 5086403341498641310 2 IN IP4 127.0.0.1\r\ns…:2\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n'}
index.js:192 signal()
index.js:930 flushing sender queue []
index.js:942 negotiated
index.js:947 signalingStateChange stable
index.js:1004 on track
index.js:1018 on stream
AppContext.js:156 --> stream from partner received
AppContext.js:157 CALL SUCCESS
index.js:1004 on track
index.js:708 iceStateChange (connection: connected) (gathering: complete)
index.js:777 maybeReady pc true channel false
index.js:438 destroying (error: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': Failed to set remote answer sdp: Called in wrong state: stable)
index.js:444 destroy (error: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': Failed to set remote answer sdp: Called in wrong state: stable)
events.js:139 Uncaught DOMException: Failed to execute 'setRemoteDescription' on 'RTCPeerConnection': Failed to set remote answer sdp: Called in wrong state: stable

Answer Logs

--> offer received
AppContext.js:46 --> OFFER {type: 'offer', sdp: 'v=0\r\no=- 5999517895916958975 2 IN IP4 127.0.0.1\r\ns…:2\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n'}
index.js:392 non-initiator initial negotiation request discarded
index.js:947 signalingStateChange have-remote-offer
index.js:1004 on track
index.js:1018 on stream
AppContext.js:82 --> stream from partner received
AppContext.js:83 CALL SUCCESS
index.js:1004 on track
index.js:930 flushing sender queue []
index.js:942 negotiated
index.js:947 signalingStateChange stable
index.js:708 iceStateChange (connection: new) (gathering: gathering)
index.js:708 iceStateChange (connection: checking) (gathering: gathering)
index.js:596 started iceComplete timeout
index.js:708 iceStateChange (connection: connected) (gathering: gathering)
index.js:777 maybeReady pc true channel false
index.js:708 iceStateChange (connection: connected) (gathering: complete)
index.js:777 maybeReady pc true channel false
index.js:669 signal
AppContext.js:76 --> sending answer
AppContext.js:77 --> ANSWER {type: 'answer', sdp: 'v=0\r\no=- 5086403341498641310 2 IN IP4 127.0.0.1\r\ns…:2\r\na=sctp-port:5000\r\na=max-message-size:262144\r\n'}
index.js:708 iceStateChange (connection: disconnected) (gathering: complete)
index.js:438 destroying (error: Connection failed.)
index.js:444 destroy (error: Connection failed.)
index.js:699 Uncaught Error: Connection failed.
    at Peer._onConnectionStateChange (index.js:699:1)
    at Peer._pc.onconnectionstatechange (index.js:118:1)
abhi-dasgupta commented 2 years ago

was a socket.io signaling issue

Galileoomega commented 2 years ago

was a socket.io signaling issue

What this even means..?

abhi-dasgupta commented 2 years ago

@Galileoomega something was wrong with my socket.io logic, which I used to send simple-peer offer/answer...