Skip to main content
JitsiConnection represents a connection to the Jitsi Meet XMPP server. It handles authentication, connection management, and provides access to conferences.

Constructor

new JitsiConnection()

Creates a new connection instance.
const connection = new JitsiMeetJS.JitsiConnection(appId, token, options);
appId
string
required
Application identifier for the Jitsi Meet service. For JaaS deployments, use your vpaas-magic-cookie-* app ID.
token
string | null
required
JWT token for authentication. Can be null for guest access.
options
object
required
Connection configuration options

Connection Management

connect()

Connects to the XMPP server.
connection.connect(options);
options
object
Connection options
Example:
connection.addEventListener(
  JitsiMeetJS.events.connection.CONNECTION_ESTABLISHED,
  () => {
    console.log('Connected!');
  }
);

connection.addEventListener(
  JitsiMeetJS.events.connection.CONNECTION_FAILED,
  (error) => {
    console.error('Connection failed:', error);
  }
);

connection.connect({ name: 'myroom' });

attach()

Attaches to an existing XMPP connection (for connection reuse).
connection.attach(options);
options
object
required

disconnect()

Disconnects from the XMPP server.
await connection.disconnect();
result
Promise<void> | boolean
Promise that resolves when disconnection is complete, or boolean for synchronous result

refreshToken()

Renews the JWT token if it’s expiring.
await connection.refreshToken(newToken);
token
string
required
The new JWT token
result
Promise<void>
Promise that resolves when token is refreshed

Conference Management

initJitsiConference()

Creates and initializes a new conference.
const conference = connection.initJitsiConference(roomName, options);
name
string
required
Conference room name (must be lowercase)
options
object
Conference configuration options. See JitsiConference for details.
conference
JitsiConference
A new JitsiConference instance
Example:
const conference = connection.initJitsiConference('myroom', {
  openBridgeChannel: true,
  p2p: {
    enabled: true
  }
});

conference.join();

Event Management

addEventListener()

Subscribes to connection events.
connection.addEventListener(event, listener);
event
string
required
Event name from JitsiMeetJS.events.connection
listener
function
required
Event handler function
Connection Events:
  • CONNECTION_ESTABLISHED - Connection successfully established
  • CONNECTION_FAILED - Connection failed (error: string, msg: string, credentials: object, details: object)
  • CONNECTION_DISCONNECTED - Connection was disconnected (msg: string)
  • WRONG_STATE - Connection is in wrong state for the operation
Example:
connection.addEventListener(
  JitsiMeetJS.events.connection.CONNECTION_ESTABLISHED,
  () => {
    console.log('Connected successfully');
    const conference = connection.initJitsiConference('room1', {});
    conference.join();
  }
);

connection.addEventListener(
  JitsiMeetJS.events.connection.CONNECTION_FAILED,
  (error, msg, credentials, details) => {
    console.error('Connection failed:', error, msg);
  }
);

removeEventListener()

Unsubscribes from connection events.
connection.removeEventListener(event, listener);
event
string
required
Event name to unsubscribe from
listener
function
required
The event handler to remove

Information Methods

getJid()

Returns the JID of the participant associated with the connection.
const jid = connection.getJid();
jid
string
Full JID of the connected participant (e.g., user@domain/resource)

getConnectionTimes()

Returns connection timing information for diagnostics.
const times = connection.getConnectionTimes();
times
object
Object containing connection timing metrics:
  • connecting - When connection started
  • connected - When connection was established
  • Various XMPP-specific timings

getLogs()

Retrieves internal connection logs for debugging.
const logs = connection.getLogs();
logs
object
Object containing:
  • metadata - Connection metadata (time, URL, user agent)
  • xmpp - XMPP protocol logs
  • Jingle session logs

Feature Management

addFeature()

Adds a feature to the local participant’s capabilities.
connection.addFeature(feature, submit);
feature
string
required
Feature URN to add (e.g., urn:xmpp:jingle:apps:dtls:0)
submit
boolean
default:"false"
If true, immediately broadcast the updated feature list

removeFeature()

Removes a feature from the local participant’s capabilities.
connection.removeFeature(feature, submit);
feature
string
required
Feature URN to remove
submit
boolean
default:"false"
If true, immediately broadcast the updated feature list

Properties

options

The connection configuration options (read-only).
const domain = connection.options.hosts.domain;

xmpp

Internal XMPP connection instance (internal use only).
This property is for internal library use. Direct manipulation may break functionality.

Build docs developers (and LLMs) love