The watchRTC SDK automatically connects to the watchRTC servers when a peer connection is created in your web application. Sometimes, application developers would rather connect earlier than that. This has the added benefit of:
- Collecting failures taking place prior to the creation of a peer connection
- Catching and logging fast failures that close the page, refresh or retry the connection before a peer connection get fully connected
This is doubly true for cases where custom events and console logs are added and collected prior to a peer connection’s creation.
To that end, you can use watchRTC.connect() API call to explicitly tell the watchRTC SDK to connect to the server. If you make use of the connect() API, you will also need to explicitly call watchRTC.disconnect() when you are done with the sessions (note that without calling connect, the watchRTC SDK will automatically disconnect once all peer connections are closed).