Skip to content

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
): Subscription

Usage Example ​

client.setSessionErrorListener { error: SessionErrorReason ->
    when (error) {
        SessionErrorReason.TokenExpired -> TODO()
        SessionErrorReason.TransportClosed -> TODO()
        SessionErrorReason.PingTimeout -> TODO()
    }
}

Event Data ​

ParameterTypeDescription
reasonSessionErrorReasonThe reason the session error occurred — see below

SessionErrorReason ​

Android / Web valueiOS valueDescription
tokenExpired / TOKEN_EXPIREDVGSessionErrorReasonTokenExpiredThe session JWT has expired
transportClosed / TRANSPORT_CLOSEDVGSessionErrorReasonTransportClosedThe WebSocket transport was closed unexpectedly
pingTimeout / PING_TIMEOUTVGSessionErrorReasonPingTimeoutThe session ping timed out, indicating a connection loss

Notes ​

  • When receiving tokenExpired, mint a fresh JWT from your backend and call createSession again
  • transportClosed and pingTimeout indicate connectivity issues — consider showing a disconnected state and attempting a new session
  • This event fires after automatic reconnection has been exhausted

Built with VitePress.