11 WebRTC Session Controller JavaScript API Error Codes and Errors

This chapter describes the error handlers and error codes provided in the Oracle Communications WebRTC Session Controller JavaScript application programming interface (API) library.

Note:

See Oracle Communications WebRTC Session Controller JavaScript API Reference for more information on the individual WebRTC Session Controller JavaScript API classes.

About wsc.ERRORCODE

The WebRTC Session Controller JavaScript API library provides the wsc.ERRORCODE enumerator object for the possible error codes. When there is an error, the appropriate error handler is called with the specific error code.

About the Error Codes

Table 11-1 lists the possible error codes and their descriptions.

Table 11-1 Error Codes and Their Descriptions

Error Code Error Constant Description

401

UNAUTHORIZED

The request requires user authentication.

403

FORBIDDEN

The server understood the request, but is refusing to fulfill it.

404

RESOURCE_UNAVAILABLE

The server has definitive information that the user does not exist at the domain specified in the Request-URI.

407

PROXYAUTH_REQUIRED

This code is similar to 401 (UNAUTHORIZED), but indicates that the client MUST first authenticate itself with the proxy.

480

TEMPORARILY_UNAVAILABLE

The callee's end system was contacted successfully but the callee is currently unavailable.

486

BUSY_HERE

The callee's end system was contacted successfully, but the callee is currently not willing or able to take additional calls at this end system.

487

REQUEST_TERMINATED

The request was terminated.

500

SYSTEM_ERROR

The server encountered an unexpected condition that prevented it from fulfilling the request.

600

BUSY_EVERYWHERE

The callee's end system was contacted successfully but the callee is busy and does not wish to take the call at this time.

603

DECLINED

The callee's machine was successfully contacted but the user explicitly does not wish to or cannot participate.

1001

WEBSOCKET_ERROR

The websocket has an error or the connection has failed.

1101

PEERCONNECTION_ERROR

The peerConnection has encountered an error.

1201

MEDIA_ERROR

The media stream has an error.

1301

RESTORE_FAILED

The session state could not be reloaded.

1302

SAVE_FAILED

The session state could not be saved.


Using wsc.ErrorInfo

The wsc.ErrorInfo object enables you to handle error scenarios in your application. use the code and reason properties to retrieve the error code and reason and process the failure scenario accordingly.

About the Error Handlers

Assign callback functions and implement the logic to perform the following tasks:

Handling Errors Related to Sessions

In our base case example, we created the wseSession object using the following statement:

wseSession = new wsc.Session(null, wsUri, sessionSuccessHandler, sessionErrorHandler);

When wseSession has an error, WebRTC Session Controller JavaScript API library invokes the callback function sessionErrorHandler() and provides the error as error, the argument in the sessionErrorHandler() callback function.

In the callback function assigned in your application to handle session-related errors, use the error.code property to display the error code and error.reason property to display the reason for the specific error as shown below in Example 11-1.

Example 11-1 Session Creation Error Handler

function sessionErrorHandler(error) {
    console.log("onSessionError: error code=" + error.code + ", reason=" + error.reason);
    setControls("<h1>Session Failed, please logout and try again.</h1>");  
    ...
  }

Take any other action as appropriate for the session-related error.

Handling Errors Related to Calls

Suppose your application uses the following statement is used to create an instance of a Call object named call:

var call = callPackage.createCall(callee, callConfig, failureCallback);

Your application may be required to handle errors related to calls the following scenarios:

  • If the call object named call is not created for some reason, Signaling Engine invokes the callback function failureCallback and provides the error as error, the argument in the failureCallback callback function.

  • Your application invokes the Call.start method for this call and the WebRTC Session Controller JavaScript API library attempts to send the request to start the call. If an exception occurs:

    • Before the WebRTC Session Controller JavaScript API library sends the request to start the call, then the failureCallback function is invoked.

      In the callback function assigned in your application to handle call-related errors, use the ErrorInfo.reason property to display the reason for the specific error as shown below in Example 11-2.

      Example 11-2 Handling Call-Related Error

      function failureCallback(error) {
          alert('Call error reason:'+error.reason);
      }
      
    • After the WebRTC Session Controller JavaScript API library sends the request to start the call, then the Signaling Engine invokes the Call.onCallStateChange event handler of the call with the call state as wsc.CALLSTATE_FAILED.

      Set up the appropriate actions in the callback function assigned in your application to Call.onCallStateChange to handle this call state.

Handling Errors Related to Data Transfers

In "Setting Up the Data Transfer State Event Handler for the Chat Session", the logic in the onDataTransfer callback function assigns onDCError as the callback function for data channel errors with the following statement:

dataTransfer.onError = onDCError;

If there is an issue in a chat session, in sending a text message or a data file, the WebRTC Session Controller JavaScript API library triggers onDCError, the error event handler and provides the appropriate error constant from the WSC.ERRORCODE enumerator object.

In the callback function assigned in your application to handle call-related errors, use the ErrorInfo.reason property to display the reason for the specific error. Take any other action as appropriate for the error.

Handling Errors Related to Subscriptions

If there is an issue in creating a subscription, Signaling Engine triggers the error event handler onError with the appropriate constant defined in the WSC.ERRORCODE enumerator object.

The following statement creates an instance of the Subscription class called subscription:

subscription = MsgAlertHandler.createNewSubscription(
      target,subscriber,onSubscribeSuccess,onSubscribeError,onNotification,onEnd, extHeaders);

Where:

  • target is the service target you obtained from the user, the device or the service the user wishes to monitor.

  • subscriber is the user identity of this subscriber.

  • onSubscribeSuccess is the event handler called when the application creates the subscription.

  • onSubscribeError is the event handler called when the application fails to create the subscription.

  • onNotification is the event handler for a notify message.

  • onEnd, is the event handler called when the provider of the notification notifies Signaling Engine that this subscription has ended.

  • extHeaders are the extension headers.

Example 11-3 shows the error callback function onSubscribeError called by an application. This function processes the error by calling removeSubscriptionInfoElem(). In this case, the removeSubscriptionInfoElem() function removes the information element for the subscription from the web application page.

Example 11-3 Subscription Creation Error

function onSubscribeError(errorObj) {
    console.log("Error code: "+errorObj.code);
    removeSubscriptionInfoElem();
  };