• Skip to Search
  • Skip to Content
  • Skip to Side Navigation
Getting StartedSDK ReferenceGlossary
  • Home
  • Getting Started
  • SDK Reference
  • Portal
  • How-To
  • Troubleshooting
  • FAQs
  • Reference
  • Glossary
Getting Started
  • Basic Demo
  • Advanced Demo
  • Real-Time Use Cases
  • Ingest Options
  • Workflow
  • Getting Started with WebSDK 2.0
  • WebSDK 2.0 Logging and Error Handling
  • Mobile App Demos
  • Training Videos

WebSDK 2.0 Logging and Error Handling

This document provides an overview of logging, channel states, and error handling in WebSDK 2.0.

Logging

Logging levels and telemetry are controlled via programmatic API. If you don't use TypeScript, WebStorm can provide code completion based on the TypeScript mapping that comes with the WebSDK 2.0.

The SDK provides log messages from the set log level along with messages from the more severe levels. For example, if you have the "Warn" level set, logs will include Warn, Error, and Fatal messages.

Prior to using the phenix.Channels APIs, use phenix.SDK.init(initOptions). These include options for logging level for both general logging and for console logging, and for telemetry.

Log level options, from lowest to highest severity, are:

  • Trace

  • Debug

  • Info

  • Warn

  • Error

  • Fatal

Other levels are "Off" to mute all log messages, and "All" to receive all log messages. Typically, there should be no issues that cause any issues above "Info"; that is, a typical run only has Info and less-severe log messages.

  • loggingLevel: one of 'Off' | 'Trace' | 'Debug' | 'Info' | 'Warn' | 'Error' | 'Fatal' | 'All'

  • consoleLoggingLevel: one of 'Off' | 'Trace' | 'Debug' | 'Info' | 'Warn' | 'Error' | 'Fatal' | 'All'

  • telemetryLevel: one of 'Off' | 'Essential' | 'All'

An example is shown below.

phenix.SDK.init({telemetryLevel: 'All', consoleLoggingLevel: 'Off'});

Error Management

Error handling is different when using WebSDK2.0 as some of the errors result from the token rather than from API calls such as joinChannel.

Detect if Unauthorized

If a token is set to null or is unauthorized, joining a channel or room will fail. In this case, implementers should obtain a new token.

JavaScript
1// Detect if the client failed to authorize
2// This could happen if the token is not valid OR if the token expired
3channel.authorized.subscribe(authorized => {
4 if (!authorized) reauthorize();
5});
6function reauthorize() {
7 let token = await acquireNewToken();
8 channel.token = token;
9}

Detect if No Video in Channel

JavaScript
1// Detect if the channel has no video
2channel.standby.subscribe(standby => {
3 // If standby, no stream playing in channel, update UI accordingly
4});

Detect if Unable to Connect

JavaScript
1// Detect if the client is unable to connect
2// This could happen if the DNS or network is changing or impaired
3channel.online.subscribe((online) => {
4 if (!online) tryAgainOrFallbackToHls();
5});

Handling Automatic Muting

JavaScript
1// Browser may refuse video playback without video being muted
2channel.autoMuted.subscribe(autoMuted => {
3 If (autoMuted) makeSureUnmuteButtonIsVisibleOnScreen();
4});
5unmuteButton.click = () => channel.unmute();

Handling Automatic Pausing

JavaScript
1// Browser may completely refuse video playback, e.g. low battery
2channel.autoPaused.subscribe((autoPaused) => {
3 if (autoPaused) makeSurePlayButtonIsVisibleOnScreen();
4});
5// Note on ios you need to use videoElement.onplay / no custom play button
6playButton.click = () => channel.resume();
Page Content
    Copyright 2023 © Phenix RTS
    Privacy Policy | Terms of Service
    v2023-01-31T21:25:10