Is there a way to "reset" the state of all WebRTC components in Chrome without refreshing the page?

2,159 views
Skip to first unread message

James Mortensen

unread,
Aug 19, 2014, 6:09:05 PM8/19/14
to discuss...@googlegroups.com
Hello,

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:

I'm getting the following error in Chrome 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.

However, 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?  Currently, I have to reload the application when the DOM enters this state.

Thank you for your assistance!
James

James Mortensen

unread,
Aug 19, 2014, 6:57:11 PM8/19/14
to discuss...@googlegroups.com
I posted this question on Stack Overflow, with more details, as this is something that's been plaguing us for awhile, and I'd really love to find an answer.  


Thank you!
James

aaroncray

unread,
Aug 19, 2014, 8:00:36 PM8/19/14
to discuss...@googlegroups.com
if the web api is anything like the mobile ones you should be able to call close() on the peerconnection which should give you the desired state reset you're looking for. My bad if there isn't that method on the web api


On Tuesday, August 19, 2014 3:09:05 PM UTC-7, James Mortensen wrote:

James Mortensen

unread,
Aug 19, 2014, 9:27:03 PM8/19/14
to discuss...@googlegroups.com
It's still too early to tell for sure, but in the area of the code where I was destroying the peerConnection, I made sure to check the signalingState beforehand, and if it was not 'closed', I called .close() before setting it to null.

So far it has taken the beating of me clicking call and hangup repeatedly, so even though there's no "master peerConnection" or "master reset button", this may solve the problem.  

Thank you for your help!  
James
Reply all
Reply to author
Forward
0 new messages