Handling reconnection and network migration on mobile devices with the Vonage Video API.
- Mobile Devices
- Network Migration
- Video API
The transition between WiFi and WWAN (cellular) networks can sometimes present issues for your application workflow. The recommended approach is reliant on the client application controller.
In order to preserve state machine synchronization between client and server, we recommend client applications observe network reachability and issue reconnect workflows whenever reachability has changed. Disconnect the session and release any objects retained in the application controller. After the sessionDisconnected callback fires, it is safe to reconnect to the session. Developers may choose to reallocate at this time as well.
Server Timeouts and Stale Objects
When reconnecting to a session, be aware that the Vonage Video API server may not have recognized that the device has yet disconnected. The previous connection ID for the same device might stay on the session for up to 30 seconds, until timed out by the server. When the device reconnects, it should be prepared to handle connection and stream events for the previous connection and stream objects (if publishing before reconnect).
In our example, a list is used to store connection and stream IDs prior to disconnecting and reconnecting. Prior to processing stream and connection events, the controller checks if the identifier should be ignored, and discards the event if so. Additional signaling may be necessary to provide similar behavior for other participants in the session, but this is largely application specific. Consider using token data to uniquely identify users and devices, rather than rely directly on stream and connection IDs.
The SDK does not attempt to migrate from WWAN to WiFi when a WiFi network becomes connected. We recommend taking similar considerations for the reconnect workflow whether moving on or off of WiFi.