Skip to main content
The JitsiConnection class manages the XMPP connection to Jitsi Meet servers and provides the foundation for creating conferences.

Overview

JitsiConnection handles:
  • XMPP connection establishment and lifecycle
  • Authentication with JWT tokens or passwords
  • Connection state management
  • Conference creation
  • Feature advertising

Creating a Connection

Connections are created using the main library API:

Constructor Parameters

From JitsiConnection.ts:16-34:

Connection Lifecycle

Connecting

The connect() method establishes the XMPP connection:
From JitsiConnection.ts:105-120:
The connection can send an HTTP conference request to Jicofo before establishing the XMPP connection when both options.name is provided and the redirect URL is configured.

Attaching to Existing Connection

For optimization, you can attach to an existing connection:

Disconnecting

Clean up the connection:
From JitsiConnection.ts:138-144:

Connection Events

All connection events are defined in JitsiConnectionEvents.ts:5-60:

CONNECTION_ESTABLISHED

Fired when the connection is successfully established:
Parameters:
  • id (string) - The ID of the local endpoint/participant/peer

CONNECTION_FAILED

Fired when connection fails:
Parameters:
  • errType (JitsiConnectionErrors) - The type of error
  • errReason (string) - Error message
  • credentials (object) - Credentials used to connect
  • errReasonDetails (object) - Additional error details for analytics

CONNECTION_DISCONNECTED

Fired when connection is closed:
Parameters:
  • msg (string) - Message associated with disconnect (e.g., last error)

Other Connection Events

Authentication

JWT Token Authentication

Provide a JWT token during construction:

Token Refresh

Renew tokens before expiration:
From JitsiConnection.ts:159-163:
Token refresh is critical for long-running conferences. Implement token renewal before expiration to avoid disconnection.

Password Authentication

Provide credentials in the connect options:

Creating Conferences

Once connected, create a conference:
From JitsiConnection.ts:173-179:
Room names must be lowercase. The constructor will throw an error if the name contains uppercase characters.

Feature Management

Advertise client capabilities:
From JitsiConnection.ts:214-227:
Parameters:
  • feature - Feature name (usually URN format)
  • submit - If true, immediately submit the new feature list to peers

Utilities

Get Connection JID

Retrieve the participant’s JID:

Connection Times

Get connection timing information for analytics:

Connection Logs

Retrieve internal logs for debugging:
From JitsiConnection.ts:233-251:

Best Practices

Always listen for connection events to handle failures gracefully:
Implement token refresh before expiration:
Always disconnect properly to free resources:

JitsiConference

Learn about conference lifecycle and room management

Architecture

Understand the overall library architecture