Options
All
  • Public
  • Public/Protected
  • All
Menu

Class JanusAdmin

Janus Admin API

const adminTransport = ...;
await adminTransport.waitForReady();
const admin = new JanusAdmin(...);

...

await adminTransport.dispose();
export

Hierarchy

  • JanusAdmin

Index

Constructors

constructor

  • Creates an instance of JanusAdmin.

    memberof

    JanusAdmin

    Parameters

    • transport: ITransport

      which transport to use. i.e. WebSocket, HTTP or EventClientTranport

    • admin_secret: string

      admin secret needed for some or all the APIs

    Returns JanusAdmin

Accessors

admin_secret

  • get admin_secret(): string
  • Retrieve the admin secret used to initialize this instance

    readonly
    memberof

    JanusAdmin

    Returns string

Methods

accept_new_sessions

  • accept_new_sessions(accept: boolean): Promise<boolean>
  • configure whether Janus should accept new incoming sessions or not; this can be particularly useful whenever, e.g., you want to stop accepting new sessions because you're draining this instance

    const admin = new JanusAdmin(...);
    const accept = await admin.accept_new_sessions(true);
    ...

    Parameters

    • accept: boolean

    Returns Promise<boolean>

add_token

  • add_token(token: string, plugins?: string[]): Promise<string[]>
  • add a valid token (only available if you enabled the Stored token based authentication mechanism)

    memberof

    JanusAdmin

    const admin = new JanusAdmin(...);
    const token = await admin.add_token('abcd',['janus.plugin.videoroom']);
    ...

    Parameters

    • token: string

      token to add

    • Optional plugins: string[]

      which plugins to enable for that token

    Returns Promise<string[]>

allow_token

  • allow_token(token: string, plugins: string[]): Promise<string[]>
  • give a token access to a plugin (only available if you enabled the Stored token based authentication mechanism)

    const admin = new JanusAdmin(...);
    const allowed = await admin.allow_token('abcd',['janus.plugin.audiobridge']);
    ...

    Parameters

    • token: string
    • plugins: string[]

    Returns Promise<string[]>

custom_event

  • custom_event<T>(schema: string, data: T): Promise<boolean>
  • push a custom "external" event to notify via event handlers; this can be useful whenever info from a third-party application needs to be easily correlated to events originated by Janus, or to push information Janus doesn't have available (e.g., a script polling CPU usage regularly)

    const admin = new JanusAdmin(...);
    const response = await admin.custom_event("janus/events", { test: "valuetest" });

    Type parameters

    • T

    Parameters

    • schema: string
    • data: T

    Returns Promise<boolean>

custom_logline

  • custom_logline(line: string, level: number): Promise<boolean>
  • push a custom "external" string to print on the logs; this can be useful whenever info from a third-party application needs to be injected in the Janus logs for whatever reason. The log level can be chosen.

    const admin = new JanusAdmin(...);
    const response = await admin.custom_logline("test line", 4);

    Parameters

    • line: string
    • level: number

    Returns Promise<boolean>

destroy_session

  • destroy_session(session: number): Promise<string>
  • destroy a specific session; this behaves exactly as the destroy request does in the Janus API

    Parameters

    • session: number
      const admin = new JanusAdmin(...);
      const success = await admin.destroy_session();
      ...

    Returns Promise<string>

detach_handle

  • detached a specific handle; this behaves exactly as the detach request does in the Janus API

    const admin = new JanusAdmin(...);
    const pluginHandle : PluginHandle = ...;
    const handle_info = await admin.detach_handle(pluginHandle);
    ...

    Parameters

    Returns Promise<boolean>

disallow_token

  • disallow_token(token: string, plugins: string[]): Promise<string[]>
  • remove a token access from a plugin (only available if you enabled the Stored token based authentication mechanism)

    const admin = new JanusAdmin(...);
    const allowed = await admin.disallow_token('abcd',['janus.plugin.audiobridge']);
    ...

    Parameters

    • token: string
    • plugins: string[]

    Returns Promise<string[]>

get_status

  • returns the current value for the settings that can be modified at runtime via the Admin API (see below)

    const admin = new JanusAdmin(...);
    const status = await admin.get_status();
    ...

    Returns Promise<IServerStatusResponse>

handle_info

  • list all the available info on a specific ICE handle

    const admin = new JanusAdmin(...);
    const pluginHandle : PluginHandle = ...;
    const session : JanusSession = ...;
    const handle_info = await admin.handle_info(session,pluginHandle,false);
    ...

    Parameters

    Returns Promise<IHandleInfo>

hangup_webrtc

  • hangups the PeerConnection associated with a specific handle; this behaves exactly as the hangup request does in the Janus API

    const admin = new JanusAdmin(...);
    const pluginHandle : PluginHandle = ...;
    const handle_info = await admin.hangup_webrtc(pluginHandle);
    ...

    Parameters

    Returns Promise<boolean>

info

  • get the generic on the Janus instance; this returns exactly the same information that a Janus API info request would return, and doesn't require any secret;

    const admin = new JanusAdmin(...);
    const server_info = await admin.info();

    Returns Promise<IServerInfoResponse>

list_handles

  • list all the ICE handles currently active in a Janus session (returns an array of handle identifiers)

    const admin = new JanusAdmin(...);
    const session : JanusSession = ...;
    const handles = await admin.list_handles(session);
    ...

    Parameters

    Returns Promise<number[]>

list_sessions

  • list_sessions(): Promise<number[]>
  • list all the sessions currently active in Janus (returns an array of session identifiers)

    const admin = new JanusAdmin(...);
    const sessions = await admin.list_sessions();
    ...

    Returns Promise<number[]>

list_tokens

  • list the existing tokens (only available if you enabled the Stored token based authentication mechanism)

    const admin = new JanusAdmin(...);
    const tokens = await admin.list_tokens();
    ...

    Returns Promise<ITokenItem[]>

message_plugin

  • message_plugin<TResponse>(plugin: string, request: any): Promise<TResponse>
  • send a synchronous request to a plugin and return a response; implemented by most plugins to facilitate and streamline the management of plugin resources (e.g., creating rooms in a conference plugin)

    const admin = new JanusAdmin(...);
    const listReq: IListRequest = {
            request: "list"
    };
    
    const response = await admin.message_plugin<IListResponse>("janus.plugin.videoroom", listReq);

    Type parameters

    • TResponse

    Parameters

    • plugin: string
    • request: any

    Returns Promise<TResponse>

ping

  • ping(): Promise<string>
  • a simple ping/pong mechanism for the Admin API, that returns a pong back that the client can use as a healthcheck or to measure the protocol round-trip time

    const admin = new JanusAdmin(...);
    const reply = await admin.ping();
    console.log(reply); // pong

    Returns Promise<string>

query_eventhandler

  • query_eventhandler<TRequest, TResponse>(handler: string, request: TRequest): Promise<TResponse>
  • send a synchronous request to an event handler and return a response; implemented by most event handlers to dynamically configure some of their properties

    const admin = new JanusAdmin(...);
    const request: IMQTTEVHRequest = {
            "request": "tweak",
            "events": "all"
    };
    
    const response = await admin.query_eventhandler<IMQTTEVHRequest, any>("janus.eventhandler.mqttevh", request);

    Type parameters

    • TRequest

    • TResponse

    Parameters

    • handler: string
    • request: TRequest

    Returns Promise<TResponse>

remove_token

  • remove a token (only available if you enabled the Stored token based authentication mechanism)

    const admin = new JanusAdmin(...);
    const success = await admin.remove_token('abcd');
    ...

    Parameters

    • token: string

    Returns Promise<ITokenPlugins>

resolve_address

  • resolve_address(address: string): Promise<{ elapsed: number; ip: string }>
  • helper request to evaluate whether this Janus instance can resolve an address via DNS, and how long it takes

    const admin = new JanusAdmin(...);
    const response = await admin.resolve_address("www.google.com");

    Parameters

    • address: string

    Returns Promise<{ elapsed: number; ip: string }>

set_libnice_debug

  • set_libnice_debug(debug: boolean): Promise<boolean>
  • selectively enable/disable libnice debugging

    const admin = new JanusAdmin(...);
    const libnice_debug = await admin.set_libnice_debug(true);
    ...

    Parameters

    • debug: boolean

    Returns Promise<boolean>

set_locking_debug

  • set_locking_debug(debug: boolean): Promise<boolean>
  • selectively enable/disable a live debugging of the locks in Janus on the fly (useful if you're experiencing deadlocks and want to investigate them)

    const admin = new JanusAdmin(...);
    const locking_debug = await admin.set_locking_debug(true);
    ...

    Parameters

    • debug: boolean

    Returns Promise<boolean>

set_log_colors

  • set_log_colors(colors: boolean): Promise<boolean>
  • selectively enable/disable using colors in all log lines Janus writes on the console and/or to file

    const admin = new JanusAdmin(...);
    const colors = await admin.set_log_colors(true);
    ...

    Parameters

    • colors: boolean

    Returns Promise<boolean>

set_log_level

  • set_log_level(level: number): Promise<number>
  • change the log level in Janus on the fly

    memberof

    JanusAdmin

    const admin = new JanusAdmin(...);
    const level = await admin.set_log_level(4);
    ...

    Parameters

    • level: number

      0-7 where 0 is no log and 7 is debug log

    Returns Promise<number>

set_log_timestamps

  • set_log_timestamps(timestamps: boolean): Promise<boolean>
  • selectively enable/disable adding a timestamp to all log lines Janus writes on the console and/or to file

    const admin = new JanusAdmin(...);
    const timestamps = await admin.set_log_timestamps(true);
    ...

    Parameters

    • timestamps: boolean

    Returns Promise<boolean>

set_min_nack_queue

  • set_min_nack_queue(min_nack_queue: number): Promise<number>
  • change the value of the min NACK queue window

    memberof

    JanusAdmin

    const admin = new JanusAdmin(...);
    const nack_queue = await admin.set_min_nack_queue(200);
    ...

    Parameters

    • min_nack_queue: number

      minimum NACK queue in ms

    Returns Promise<number>

set_no_media_timer

  • set_no_media_timer(no_media_timer: number): Promise<number>
  • change the value of the no-media timer value on the fly

    memberof

    JanusAdmin

    const admin = new JanusAdmin(...);
    const no_media_timer = await admin.set_no_media_timer(5);
    ...

    Parameters

    • no_media_timer: number

      no-media timer in seconds

    Returns Promise<number>

set_refcount_debug

  • set_refcount_debug(debug: boolean): Promise<boolean>
  • selectively enable/disable a live debugging of the reference counters in Janus on the fly (useful if you're experiencing memory leaks in the Janus structures and want to investigate them)

    Parameters

    • debug: boolean

      reference counters debug

      const admin = new JanusAdmin(...);
      const refcount_debug = await admin.set_refcount_debug(true);
      ...

    Returns Promise<boolean>

set_session_timeout

  • set_session_timeout(timeout: number): Promise<number>
  • change the session timeout value in Janus on the fly

    memberof

    JanusAdmin

    const admin = new JanusAdmin(...);
    const timeout = await admin.set_session_timeout(5); //seconds
    ...

    Parameters

    • timeout: number

      session timeout in seconds

    Returns Promise<number>

set_slowlink_threshold

  • set_slowlink_threshold(slowlink_threshold: number): Promise<number>
  • change the value of the slowlink-threshold property which is the number of lost packets that trigger slow link

    Parameters

    • slowlink_threshold: number

      number of packets to trigger slowlink

      const admin = new JanusAdmin(...);
      const slowlink_threshold = await admin.set_slowlink_threshold(4);
      ...

    Returns Promise<number>

start_pcap

  • start_pcap(handle: PluginHandle, folder: string, filename: string, truncate: number): Promise<boolean>
  • start dumping incoming and outgoing RTP/RTCP packets of a handle to a pcap file (e.g., for ex-post analysis via Wireshark) list all the available info on a specific ICE handle

    const admin = new JanusAdmin(...);
    const pluginHandle : PluginHandle = ...;
    const started = await admin.start_pcap(pluginHandle,"/var/tmp","test.cap", 1024);
    ...

    Parameters

    • handle: PluginHandle
    • folder: string
    • filename: string
    • truncate: number

    Returns Promise<boolean>

start_text2pcap

  • start_text2pcap(handle: PluginHandle, folder: string, filename: string, truncate: number): Promise<boolean>
  • start dumping incoming and outgoing RTP/RTCP packets of a handle to a text2pcap file (e.g., for ex-post analysis via Wireshark)

    const admin = new JanusAdmin(...);
    const pluginHandle : PluginHandle = ...;
    const started = await admin.start_text2pcap(pluginHandle,"/var/tmp","test.cap.txt", 1024);
    ...

    Parameters

    • handle: PluginHandle
    • folder: string
    • filename: string
    • truncate: number

    Returns Promise<boolean>

stop_pcap

  • stop the pcap dump

    const admin = new JanusAdmin(...);
    const pluginHandle : PluginHandle = ...;
    const stopped = await admin.stop_pcap(pluginHandle);
    ...

    Parameters

    Returns Promise<boolean>

stop_text2pcap

  • stop the text2pcap dump

    const admin = new JanusAdmin(...);
    const pluginHandle : PluginHandle = ...;
    const stopped = await admin.stop_text2pcap(pluginHandle);
    ...

    Parameters

    Returns Promise<boolean>

test_stun

  • test_stun(address: string, port: number, localport?: number): Promise<{ elapsed: number; public_ip: string; public_port: number }>
  • helper request to evaluate whether this Janus instance can contact a STUN server, what is returned, and how long it takes.

    const admin = new JanusAdmin(...);
    const response = await admin.test_stun("stun.l.google.com", 19302);

    Parameters

    • address: string
    • port: number
    • Optional localport: number

    Returns Promise<{ elapsed: number; public_ip: string; public_port: number }>

Generated using TypeDoc