question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

InvalidStateError: Failed to set remote answer sdp: Called in wrong state: kStable

See original GitHub issue

hey there,

I have implemented simple-peer.js and I have the error when I send the answer : InvalidStateError: Failed to set remote answer sdp: Called in wrong state: kStable

Here is my config :

let p = new Peer({
  			 initiator: initiator,
  			 stream: stream,
  			 config:
  			  {
			    'iceServers': [
				     {
				      'urls': 'stun:eu-xxxxx.com'
				    },
				    {
				      'urls': 'turn:eu-xxxxx=udp',
				      'credential': 'xxxxxxxx',
				      'username': 'xxxxxx'
				    },
				  ]
				},
  			 trickle:false
  			})

Have you an idea to fix this error ?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:12

github_iconTop GitHub Comments

2reactions
godexsoftcommented, Apr 16, 2020

I have tracked down the issue by pure luck. Since most of us are probably started off the same tutorials… the issue only happens with more than 2 connections (peers). And the issue is this:

    onSignalingMessage = data => {
        let msg = JSON.parse(data);
    
        // make sure the message is for us
        // this lines were missing but without this it's broken
        if (msg.from != this.peerClient)
            return;
    
        // ... handling connection-answer, new-ice-candidate here ...
    }

The peerClient and msg.from are arbitrary Identifier of your peer between your javascript and the signaling server.

Basically what happens is you are trying to set an answer or ice-candidate on the wrong peer and they don’t like it 😃

Hope this helps.

1reaction
Dprosevskicommented, Dec 15, 2020

my error was because i was accidentally creating peer with the current user’s connectionId instead of the connectionId of the user im trying to connect to…

Read more comments on GitHub >

github_iconTop Results From Across the Web

Failed to set remote answer sdp: Called in wrong state: stable
The reason why you are getting this error message is because when a third user joins, it sends an offer to the 2...
Read more >
RTCPeerConnection setting offer sdp does not match the ...
Failed to create session description: InvalidStateError: Failed to execute ... Failed to set remote answer sdp: Called in wrong state: kStable.
Read more >
RE: InvalidStateError: Failed to set remote answer sdp: Called in ...
openmeetings.apache.org> Objet : RE: InvalidStateError: Failed to set remote answer sdp: Called in wrong state: kStable I have just tried with chrome in ......
Read more >
3410 - Failed to set remote offer sdp: Called in wrong state
Hi Braveyao, Thanks for the response, This was the offer SDP problem, instead of answer SDP, offer SDP is sent.
Read more >
Failed to set remote answer sdp: Called in wrong state: kStable
Why is this error happening and when is the signalling state of peer = “stable”
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found