For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
Log inSign up
Support
GuidesReferenceClick-to-Call
GuidesReferenceClick-to-Call
  • Core
    • Overview
  • Entities
    • SignalWire
      • applySelectedAudioOutputDevice
      • audioInputDevices$
      • audioInputDisabled$
      • audioOutputDevices$
      • clearDeviceState
      • connect
      • destroy
      • destroyed$
      • deviceInfoToConstraints
      • deviceRecovered$
      • dial
      • directory$
      • disableAudioInput
      • disableDeviceMonitoring
      • disableVideoInput
      • disconnect
      • enableAudioInput
      • enableDeviceMonitoring
      • enableVideoInput
      • enumerateDevices
      • errors$
      • exportDiagnostics
      • getDeviceCapabilities
      • isConnected$
      • isRegistered$
      • isValidDevice
      • platformCapabilities
      • preflight
      • ready$
      • register
      • requestMediaPermissions
      • resetToDefaults
      • selectAudioInputDevice
      • selectAudioOutputDevice
      • selectedAudioInputDevice$
      • selectedAudioInputDeviceConstraints
      • selectedAudioOutputDevice$
      • selectedVideoInputDevice$
      • selectedVideoInputDeviceConstraints
      • selectVideoInputDevice
      • session
      • setStorageManager
      • unregister
      • user$
      • videoInputDevices$
      • videoInputDisabled$
      • warnings$
    • Address
    • Participant
    • ClientPreferences
    • SelfCapabilities
    • SelfParticipant
    • User
    • WebRTCCall
  • Web Components
    • Overview
    • sw-audio-level
    • sw-call-controls
    • sw-call-dialpad
    • sw-call-media
    • sw-call-provider
    • sw-call-status
    • sw-call-widget
    • sw-click-to-call
    • sw-device-selector
    • sw-directory
    • sw-local-camera
    • sw-participant-controls
    • sw-participants
    • sw-self-media
    • sw-ui-alert
    • sw-ui-background
    • sw-ui-call-layout
    • sw-ui-content-drawer
    • sw-ui-control-bar
    • sw-ui-dialpad
    • sw-ui-dropup
    • sw-ui-icon
    • sw-ui-modal
    • sw-ui-responsive-container
    • sw-ui-split-button
    • sw-ui-transcript-view
LogoLogoSignalWire Docs
Log inSign up
Support
On this page
  • Reconnection behavior
  • Message handling during temporary disconnections
  • Returns
  • Examples
EntitiesSignalWire

connect

|View as Markdown|Open in Claude|
Was this page helpful?
Edit this page
Previous

destroy

Next
Built with
1connect(): Promise<void>

Establishes the WebSocket connection and authenticates the session.

Reconnection behavior

After a successful connection the underlying WebSocketController automatically attempts to reconnect whenever the socket closes unexpectedly (e.g. network change, server restart). Reconnection uses an exponential back-off strategy:

  • First retry after reconnectDelayMin (default 0.1 s).
  • Each subsequent retry doubles the delay up to reconnectDelayMax (default 3 s).
  • The delay resets to reconnectDelayMin once a connection succeeds.
  • A per-attempt connectionTimeout (default 10 s) aborts the attempt and schedules the next retry if the server does not respond.

Calling disconnect stops the reconnection loop entirely.

Message handling during temporary disconnections

While the socket is not in the connected state, outgoing messages are queued in an internal buffer. Once the connection is re-established the queue is flushed in order so no outgoing RPC call is lost.

Incoming server-to-client messages that arrive while the socket is down are not buffered by the SDK — they are expected to be re-delivered by the server after the session is re-authenticated. Active RPC calls that were awaiting a response will time out (default 5 s) and reject with an RPCTimeoutError; callers should handle this and retry if appropriate.

The connection status can be observed via the status$ observable on the transport layer, which emits 'connecting', 'connected', 'reconnecting', 'disconnecting', or 'disconnected'.

Returns

Promise<void>

Examples

1await client.connect();