Skip to main content
Configuration options used when connecting to a LiveKit room.

Properties

autoSubscribe
Bool
default:"true"
Automatically subscribe to remote participants’ tracks.
reconnectAttempts
Int
default:"10"
The number of attempts to reconnect when the network disconnects.
reconnectAttemptDelay
TimeInterval
default:"0.3"
The minimum delay value for reconnection attempts in seconds.This value serves as the starting point for the easeOutCirc reconnection curve.
reconnectMaxDelay
TimeInterval
default:"7.0"
The maximum delay between reconnect attempts in seconds.The reconnection delay uses an “easeOutCirc” curve between reconnectAttemptDelay and reconnectMaxDelay:
  • For all attempts except the last, the delay follows this curve
  • The curve grows rapidly at first and then more gradually approaches the maximum
  • The last attempt always uses exactly reconnectMaxDelay
Example for 10 reconnection attempts with baseDelay=0.3s and maxDelay=7s:
  • Attempt 0: ~0.85s (12% of the way to max)
  • Attempt 1: ~2.2s (30% of the way to max)
  • Attempt 2: ~3.4s (45% of the way to max)
  • Attempt 5: ~5.9s (82% of the way to max)
  • Attempt 9: 7.0s (exactly maxDelay)
socketConnectTimeoutInterval
TimeInterval
The timeout interval for the initial websocket connection.
primaryTransportConnectTimeout
TimeInterval
Timeout for the primary transport connection.
publisherTransportConnectTimeout
TimeInterval
Timeout for the publisher transport connection.
iceServers
[IceServer]
default:"[]"
Custom ICE servers for WebRTC connection.
iceTransportPolicy
IceTransportPolicy
default:".all"
ICE transport policy for WebRTC connection.
isDscpEnabled
Bool
default:"false"
Allows DSCP codes to be set on outgoing packets when network priority is used.
enableMicrophone
Bool
default:"false"
Enable microphone concurrently while connecting.
protocolVersion
ProtocolVersion
default:".v16"
LiveKit server protocol version to use. Generally, it’s not recommended to change this.

Usage

let options = ConnectOptions(
    autoSubscribe: true,
    reconnectAttempts: 10,
    reconnectAttemptDelay: 0.3,
    reconnectMaxDelay: 7.0
)

try await room.connect(url, token, connectOptions: options)

Build docs developers (and LLMs) love