On Reconnecting
Fired when the SDK detects a connection drop and begins automatically attempting to restore the session. No user action is required — show a "reconnecting" indicator in your UI.
Event Registration
fun setReconnectingListener(
fn: () -> Unit
): SubscriptionUsage Example
client.setReconnectingListener {
println("Session Reconnecting")
}
Event Data
This event carries no parameters. Why the connection dropped (for example a transport close or a missed heartbeat) is in the SDK's logs, not in the event.
Notes
- The SDK automatically attempts to reconnect when the underlying WebSocket connection drops, or when nothing has been heard from Vonage for more than 45 seconds (for example after the app was frozen or suspended)
- It retries after 1, 2 and 4 seconds, then every 5 seconds with jitter, resuming the same session for up to 15 minutes. On the web it also retries at once when the browser comes back online
- Show a reconnecting indicator in your UI when this event fires
- Successful reconnection is indicated by
onReconnection - If the session cannot be restored,
onSessionErrorfires instead
Related Actions
createSession- Create or re-establish a session
Related Events
onReconnection- Fired when session reconnection succeedsonSessionError- Fired when a session error occurs