Question:
How does one go about resetting the state of WebRTC components in Chrome -- without reloading the page -- when they're kicked into an invalid state? See below for more details about how I'm replicating this state, and why I'm asking this:
Problem description:
I'm getting the following error in Chrome 35/node-webkit 0.10.0 when trying to set Ice Candidates when making a call:
Failed to execute 'addIceCandidate' on 'RTCPeerConnection': The ICE candidate could not be added.
Now, I know why it's happening. I'm working on making a ROBUST WebRTC application that can handle some normal user abuse. To replicate this state, I basically have to make a couple WebRTC calls and then kill them real fast and then immediately try another call. I'm guessing this must kick the PeerConnection and other components into a different state where it's expecting B to happen, but I'm starting over again with A. This is evidenced by the following error message:
Failed to set session description: Failed to set remote answer sdp: Called in wrong state: STATE_INIT
Now, Most of the WebRTC demos we see on the Internet, like http://apprtc.appspot.com, are stateless, and the browser is refreshed often, which results in resetting the DOM state. So, for those developers, the answer is easy. Just reload the page and call it good.
Currently, I have to reload the application when the DOM enters this state. However, that's not an acceptable solution, since I'm building a single page application, not a website,
I'm wondering if there is a way to make a call to the API to tell it to reset the state of whatever it is that is throwing these errors?
Some troubleshooting steps:
I tried the following, from the JavaScript console in node-webkit (Chrome 35), to see if I can manually reset the state of the PeerConnection, but it isn't helping:
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's the output of some of the peerConnection properties:
peerConn.signalingState --> "closed"
peerConn.iceConnectionState --> "closed"
peerConn.iceGatheringState --> "complete"