Skip to content

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
): 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 / EXPIRED_TOKENVGSessionErrorReasonTokenExpiredThe session ended because its JWT expired. Call refreshSession with a new token before it expires, or createSession with a new token now.
TransportClosed / TRANSPORT_CLOSEDVGSessionErrorReasonTransportClosedThe 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_TIMEOUTVGSessionErrorReasonPingTimeoutDeprecated — 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 call createSession again
  • When receiving TransportClosed, call createSession again 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 onReconnecting at once and retries after 1, 2 and 4 seconds, then every 5 seconds, resuming the same session for up to 15 minutes
  • connectionStatus becomes Disconnected exactly when this event fires
  • See Troubleshooting for every session error

Built with VitePress.