Question:
How to reset the state of WebRTC components in Chrome - without reloading the page - when they are kicked out of an invalid state? For more information on how I replicate this state, and why I ask about it, see below:
Description of the problem:
I get the following error in Chrome 35 / node -webkit 0.10.0 when trying to install Ice Candidates when making a call:
Failed to execute 'addIceCandidate' in 'RTCPeerConnection': ICE candidate could not be added.
Now I know why this is happening. I am working on a ROBUST WebRTC application that can handle some of the normal issues. To reproduce this state, I basically have to make a couple of WebRTC calls, and then quickly kill them, and then try another call right away. I assume that this should cause PeerConnection and other components to switch to a different state, where B is expected to wait, but I start over with A. The following error message indicates this:
Failed to set session description: Failed to set remote sdp response: Called in the wrong state: STATE_INIT
Now, most of the WebRTC demos we see on the Internet, such as http://apprtc.appspot.com , are stateless, and the browser is frequently updated, which causes the DOM to reset. So for those developers, the answer is simple. Just reload the page and name it well.
Currently, I have to restart the application when the DOM enters this state. However, this is not an acceptable solution, as I am creating a one-page application, not a website,
I am wondering if there is a way to make an API call to inform it of a reset state that it is throwing these errors?
Some troubleshooting steps:
I tried the following: from the JavaScript console in node -webkit (Chrome 35) to find out if I can manually reset the state of PeerConnection, but this does not help:
var properties = {}; properties.pcConfig = { "iceServers": [{ "url": "stun:stun.l.google.com:19302" }] }; properties.pcConstraints = { "optional": [] }; peerConn = new RTCPeerConnection(properties.pcConfig, properties.pcConstraints); peerConn.close();
Here is the output of some peerConnection properties:
peerConn.signalingState --> "closed" peerConn.iceConnectionState --> "closed" peerConn.iceGatheringState --> "complete"