On Session Error
Fired when the session has ended and will not recover on its own: the connection could not be restored within the server's session window, or the server ended the session or rejected the token. Use the reason to determine the appropriate recovery action.
Event Registration
fun setSessionErrorListener(
fn: (reason: SessionErrorReason) -> Unit
): SubscriptionUsage Example
client.setSessionErrorListener { error: SessionErrorReason ->
when (error) {
SessionErrorReason.TokenExpired -> TODO()
SessionErrorReason.TransportClosed -> TODO()
SessionErrorReason.PingTimeout -> TODO()
}
}
Event Data
| Parameter | Type | Description |
|---|---|---|
reason | SessionErrorReason | The reason the session error occurred — see below |
SessionErrorReason
| Android / Web value | iOS value | Description |
|---|---|---|
TokenExpired / EXPIRED_TOKEN | VGSessionErrorReasonTokenExpired | The session ended because its JWT expired. Call refreshSession with a new token before it expires, or createSession with a new token now. |
TransportClosed / TRANSPORT_CLOSED | VGSessionErrorReasonTransportClosed | The connection to Vonage was lost and could not be restored within 15 minutes, so Vonage has ended the session. Calls cannot be made or received until you call createSession again; do it when the device is back online. Also reported when the server ends the session for any other reason. |
PingTimeout / PING_TIMEOUT | VGSessionErrorReasonPingTimeout | Deprecated — never reported, removed in v3. A missed heartbeat is a transient drop, surfaced through onReconnecting |
Notes
- When receiving
TokenExpired, mint a fresh JWT from your backend and callcreateSessionagain - When receiving
TransportClosed, callcreateSessionagain once the device is back online; the same JWT works if it has not expired - A dropped connection does not fire this event: the SDK reports
onReconnectingat once and retries after 1, 2 and 4 seconds, then every 5 seconds, resuming the same session for up to 15 minutes connectionStatusbecomesDisconnectedexactly when this event fires- See Troubleshooting for every session error
Related Actions
createSession- Create a new session after error recoverydeleteSession- Clean up the current session
Related Events
onReconnecting- Fired when the session begins reconnectingonReconnection- Fired when the session reconnects successfully