On Session Error
Fired when a session-level error occurs, such as a failed reconnection attempt or a token expiry. 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 / TOKEN_EXPIRED | VGSessionErrorReasonTokenExpired | The session JWT has expired |
transportClosed / TRANSPORT_CLOSED | VGSessionErrorReasonTransportClosed | The WebSocket transport was closed unexpectedly |
pingTimeout / PING_TIMEOUT | VGSessionErrorReasonPingTimeout | The session ping timed out, indicating a connection loss |
Notes
- When receiving
tokenExpired, mint a fresh JWT from your backend and callcreateSessionagain transportClosedandpingTimeoutindicate connectivity issues — consider showing a disconnected state and attempting a new session- This event fires after automatic reconnection has been exhausted
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