Just Begin Again (ICE Restart)
Where do we, well, start? First a quick word about ICE itself. ICE stands for Interactive Connectivity Establishment, and, at its root, is how your browser discovers exactly how to connect to other computers through a NAT for WebRTC calls. ICE restart becomes necessary when network conditions change such as when transitioning from WiFi to a cellular network, or between two different WiFi networks.
OK. I hear you asking, “How does this affect me?” Or maybe more likely, “I think this is affecting me! How can I tell?”. I’m glad you asked. First you’ll need to enable logging, and the exact steps depend on which platform you’re using.
For Windows:
cd c: set NSPR_LOG_MODULES=signaling:4 set NSPR_LOG_FILE=%TEMP%log.txt For 32-bit Windows cd "Program FilesMozilla Firefox" For 64-bit Windows cd "Program Files (x86)Mozilla Firefox" .firefox.exe
For Linux:
export NSPR_LOG_MODULES=signaling:4 export NSPR_LOG_FILE=/tmp/log.txt cd /path/to/firefox ./firefox
For Mac OS X:
export NSPR_LOG_MODULES=signaling:4 export NSPR_LOG_FILE=/tmp/log.txt cd /Applications/Firefox.app/Contents/MacOS ./firefox-bin
If you’re curious about Firefox logging, you can learn more here and here.
Once you’ve enabled logging, “Offerer restarting ice” and/or “Answerer restarting ice” will appear in the logs if ice restart is happening. It will look something like:
1963835392[102030830]: [main|PeerConnectionImpl] PeerConnectionImpl.cpp:1567: CreateOffer() 1963835392[102030830]: [main|PeerConnectionImpl] PeerConnectionImpl.cpp:1585: Offerer restarting ice
You’ll see a lot of other interesting info about what is going on as well, but the main point is that you will know for certain whether an ICE restart is happening. Mystery solved! You can also see more details about ICE negotiation by going to “about:webrtc” and viewing the Connection Log section.
Now that you can see if ICE restart is happening, it is time to talk about one of the gotchas encountered along the way to making this work. The first, most surprising realization for us was that more than one WebRTC site was requesting an ICE restart with the creation of the very first connection. We now have specific checks for handling that case, which led to (hopefully) better handling of overlapping restart cases. Any testing of conditions that lead to multiple and/or overlapping restarts are always appreciated!
For the record, ICE restart is only different from initial ICE negotiation in that during restart media continues to flow over the original network connections while the new connection is negotiated. In other words, just begin again!