Skip to main content

TelnyxRTC

The TelnyxRTC class is the main entry point for the Telnyx WebRTC JS SDK. It manages the WebSocket connection to Telnyx’s signaling server and provides methods to create calls, handle events, and control the client lifecycle.

Constructor

Creates a new client instance. Does not connect automatically — call connect() to establish the WebSocket connection. Parameters: Example:

Methods

connect()

Opens a WebSocket connection to rtc.telnyx.com and authenticates using the configured credentials.
Fires telnyx.ready on success or telnyx.error on failure.

disconnect()

Closes the WebSocket connection and cleans up all active calls.
Always call disconnect() when the user leaves your app to avoid zombie WebSocket connections. See Best Practices → Connection Lifecycle.

newCall(options)

Creates and places a new outbound call.
Parameters: Returns: Call See ICallOptions for all available options including custom headers, ICE configuration, and media settings.

off(event, handler)

Removes an event listener.

removeAllListeners()

Removes all event listeners from the client.

Properties

connection

Provides helpers to check the current connection state.

calls

An array of all active Call objects.

Events

Register event listeners using client.on(eventName, handler):

Connection Events

Call Events

Stats Events


Typical Usage


Reconnection

The SDK automatically reconnects when the WebSocket drops. You don’t need to handle this manually in most cases. For advanced reconnection handling, see Reconnection & Recovery. Key configuration:

See Also