Reconnection and Network Migration on Mobile Devices

We are beginning to address issues we have seen lately with migrating networks on multi-homed mobile devices: The transition between WiFi and WWAN (cellular) networks can sometimes present issues for your application workflow. While there is work being done on the platform that will improve support for mobile devices migrating different networks, the current recommended approach is solely reliant on the client application controller.

 

Object Management

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 & Stale Objects

When reconnecting to a session, be aware that the OpenTok 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 & 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/devices, rather than rely directly on stream and connection IDs.

 

Network Upgrading

The SDK currently 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.

Have more questions? Submit a request