Suggestions

close search

Error

Properties Methods 

The Error class is used to define the error object passed into completion handlers. Each of the following methods, which execute asynchronously, includes a completionHandler parameter:

The completionHandler parameter is a function that is called when the call to the asynchronous method succeeds or fails. If the asynchronous call fails, the completion handler function is passed an error object (defined by the Error class). The code and message properties of the error object provide details about the error.

Deprecation notice: OT.Error will not be defined in an upcoming version of OpenTok. When this happens, errors emitted by the SDK will simply be instances of standard Error objects. If your code currently checks if (error instanceof OT.Error) please replace it if (/^OT_/.test(error.name)). (The name property for all OpenTok errors with begins with 'OT_'.) Note however that this code is for the purposes of smoothly upgrading, and it may be more appropriate for your code to simply compare against the specific error you want to handle, such as if (error.name === 'OT_USER_MEDIA_ACCESS_DENIED').

Properties

Name Type Description
code Number Deprecated — the error code. Use the name property, not the code property, to identify the error programatically.

In the event of an error, the code value of the error parameter can have one of the following values:

Errors when calling Session.connect():

code Description
1004 Authentication error. Check the error message for details. This error can result if you pass in an expired token when trying to connect to a session. It can also occur if you pass in an invalid token or API key. Make sure that you are generating the token using the current version of one of the OpenTok server SDKs.
1005 Invalid Session ID. Make sure you generate the session ID using the current version of one of the OpenTok server SDKs.
1006 Connect Failed. Unable to connect to the session. You may want to have the client check the network connection.
1026 Terms of service violation: export compliance. See the Terms of Service.
2001 Connect Failed. Unexpected response from the OpenTok server. Try connecting again later.

Errors when calling Session.forceDisconnect():

code Description
1010 The client is not connected to the OpenTok session. Check that client connects successfully and has not disconnected before calling forceDisconnect().
1520 Unable to force disconnect. The client's token does not have the role set to moderator. Once the client has connected to the session, the capabilities property of the Session object lists the client's capabilities.

Errors when calling Session.forceUnpublish():

code Description
1010 The client is not connected to the OpenTok session. Check that client connects successfully and has not disconnected before calling forceUnpublish().
1530 Unable to force unpublish. The client's token does not have the role set to moderator. Once the client has connected to the session, the capabilities property of the Session object lists the client's capabilities.
1535 Force Unpublish on an invalid stream. Make sure that the stream has not left the session before you call the forceUnpublish() method.

Errors when calling Session.publish():

code Description
1010 The client is not connected to the OpenTok session. Check that the client connects successfully before trying to publish. And check that the client has not disconnected before trying to publish.
1500 Unable to Publish. This can be caused by the following:
  • The client's token does not have the role set to publish or moderator. Once the client has connected to the session, the capabilities property of the Session object lists the client's capabilities.
  • The end-user has denied access to the camera or microphone.
  • The page is loaded on HTTP in Chrome, which requires HTTPS to access the camera and microphone.
1553 WebRTC ICE workflow error. This is an error that occurs when trying to establish communication between clients in the session. Try publishing again or reconnecting to the session.
1601 Internal error -- WebRTC publisher error. Try republishing or reconnecting to the session.
2001 Publish Failed. Unexpected response from the OpenTok server. Try publishing again later.

Errors when calling Session.signal():

code Description
400 One of the signal properties — data, type, or to — is invalid. Or the data cannot be parsed as JSON.
404 The to connection does not exist.
413 The type string exceeds the maximum length (128 bytes), or the data string exceeds the maximum size (8 kB).
500 The client is not connected to the OpenTok session. Check that the client connects successfully before trying to signal. And check that the client has not disconnected before trying to signal.
2001 Signal Failed. Unexpected response from the OpenTok server. Try sending the signal again later.

Errors when calling Session.subscribe():

code Description
1013 WebRTC PeerConnection error. Try resubscribing to the stream or reconnecting to the session.
1554 WebRTC ICE workflow error. This is an error that occurs when trying to establish communication between clients in the session. Try resubscribing to the stream or reconnecting to the session.
1600 Internal error -- WebRTC subscriber error. Try resubscribing to the stream or reconnecting to the session.
2001 Subscribe Failed. Unexpected response from the OpenTok server. Try subscribing again later.

Errors when calling OT.initPublisher():

code Description
1004 Authentication error. Check the error message for details. This error can result if you pass in an expired token when trying to connect to a session. It can also occur if you pass in an invalid token or API key. Make sure that you are generating the token using the current version of one of the OpenTok server SDKs.
1550 Screen sharing is not supported (and you set the videoSource property of the options parameter of OT.initPublisher() to "application", "screen", or "window"). Before calling OT.initPublisher(), you can call OT.checkScreenSharingCapability() to check if screen sharing is supported.
1551 A screen-sharing extension needs to be registered but it is not. This error can occur when you set the videoSource property of the options parameter of OT.initPublisher() to "application", "screen", or "window". Before calling OT.initPublisher(), you can call OT.checkScreenSharingCapability() to check if screen sharing requires an extension to be registered.
1552 A screen-sharing extension is required, but it is not installed. This error can occur when you set the videoSource property of the options parameter of OT.initPublisher() to "screen". Before calling OT.initPublisher(), you can call OT.checkScreenSharingCapability() to check if screen sharing requires an extension to be installed.

Errors when calling OT.reportIssue():

code Description
2011 Error calling OT.reportIssue(). Check the client's network connection.

General errors that can occur when calling any method:

code Description
1011 Invalid Parameter. Check that you have passed valid parameter values into the method call.
2000 Internal Error. Try reconnecting to the OpenTok session and trying the action again.
message String The message string provides details about the error.

Use the name property (not the message property) to identify the error programatically.

name String A string identifying the error. Use this property (not the code property) to identify the error.

Note that for all errors, this string starts with 'OT_'.

This property is undefined for unexpected errors.

Errors that can occur when calling OT.initPublisher():

name Description
'OT_HARDWARE_UNAVAILABLE' The hardware to fulfill the user media request appears to exist but could not be acquired. It might be in use by another application.
'OT_INVALID_PARAMETER' One or more parameters was not valid or not provided.
'OT_MEDIA_ERR_ABORTED' The fetching of the stream for the video element has been aborted.
'OT_MEDIA_ERR_DECODE' A decoding error occurred while trying to play the stream in the video element.
'OT_MEDIA_ERR_NETWORK' A network error caused the stream to stop being fetched.
'OT_MEDIA_ERR_SRC_NOT_SUPPORTED' The stream has been detected to be not suitable for playback.
'OT_NOT_SUPPORTED' Something in the user media request is not supported.
'OT_NO_DEVICES_FOUND' No devices were found to provide the media stream.
'OT_NO_VALID_CONSTRAINTS' Video and audio were both disabled. You need to enable at least one.
'OT_SCREEN_SHARING_NOT_SUPPORTED' Screen sharing is not supported in the browser.
'OT_SCREEN_SHARING_EXTENSION_NOT_REGISTERED' Screen-sharing support in this browser requires an extension, but one has not been registered.
'OT_SCREEN_SHARING_EXTENSION_NOT_INSTALLED' Screen-sharing support in this browser requires an extension, but the extension is not installed.

Errors that can occur when calling OT.reportIssue():

name Description
'OT_REPORT_ISSUE_FAILED' Error calling OT.reportIssue(). Check the client\'s network connection.

Errors that can occur when calling Session.connect():

session.connect:
name Description
'OT_AUTHENTICATION_ERROR' The API key does not match the token or session.
'OT_BADLY_FORMED_RESPONSE' The JSON response from the OpenTok server was badly formed.
'OT_CONNECT_FAILED' Failed to connect to session.
'OT_EMPTY_RESPONSE_BODY' Received an unexpected empty response from the OpenTok server.
'OT_INVALID_SESSION_ID' The session ID was invalid.
'OT_INVALID_PARAMETER' One or more parameters was not valid or not provided.
'OT_NOT_CONNECTED' Couldn't perform action because you are not connected to the network.
'OT_TERMS_OF_SERVICE_FAILURE' Couldn't connect due to a terms of service violation.
'OT_INVALID_HTTP_STATUS' Received an unexpected HTTP status.
'OT_XDOMAIN_OR_PARSING_ERROR' There was a cross domain error or the server responded with invalid JSON.

Errors that can occur when calling Session.forceDisconnect():

name Description
'OT_INVALID_PARAMETER' One or more parameters was not valid or not provided.
'OT_NOT_CONNECTED' Couldn't perform action because you are not connected to the network.
'OT_PERMISSION_DENIED' This token does not allow this action. The role must be at least moderator.

Errors that can occur when calling Session.forceUnpublish():

name Description
'OT_INVALID_PARAMETER' One or more parameters was not valid or not provided.
'OT_NOT_CONNECTED' Couldn't perform action because you are not connected to the network.
'OT_PERMISSION_DENIED' This token does not allow this action. The role must be at least moderator.

Errors that can occur when calling Session.publish():

name Description
'OT_CHROME_MICROPHONE_ACQUISITION_ERROR' Chrome fails to get access to the microphone, due to a Chrome error. To work around this issue, the end-user must restart Chrome and reload your site. This is a known issue to be fixed in Chrome.
'OT_CONSTRAINTS_NOT_SATISFIED' The constraints for getting user media could not be satisfied.
'OT_CREATE_PEER_CONNECTION_FAILED' Failed to create a connection between this client and the subscriber or the OpenTok Media Router.
'OT_HARDWARE_UNAVAILABLE' The hardware to fulfill the user media request appears to exist but could not be acquired. It might be in use by another application.
'OT_ICE_WORKFLOW_FAILED' Something went wrong while establishing WebRTC connectivity.
'OT_INVALID_PARAMETER' One or more parameters was not valid or not provided.
'OT_MEDIA_ERR_ABORTED' The fetching of the stream for the video element has been aborted.
'OT_MEDIA_ERR_DECODE' A decoding error occurred while trying to play the stream in the video element.
'OT_MEDIA_ERR_NETWORK' A network error caused the stream to stop being fetched.
'OT_MEDIA_ERR_SRC_NOT_SUPPORTED' The stream has been detected to be not suitable for playback.
'OT_NO_DEVICES_FOUND' No devices were found to provide the media stream.
'OT_NO_VALID_CONSTRAINTS' Video and audio were both disabled. You need to enable at least one.
'OT_NOT_CONNECTED' Couldn't perform action because you are not connected to the network.
'OT_NOT_SUPPORTED' Something in the user media request is not supported.
'OT_PERMISSION_DENIED' This token does not allow publishing. The role must be at least publisher to enable this funcitonality.
'OT_SCREEN_SHARING_NOT_SUPPORTED' Screen sharing is not supported in the browser.
'OT_SCREEN_SHARING_EXTENSION_NOT_REGISTERED' Screen-sharing support in this browser requires an extension, but one has not been registered.
'OT_SCREEN_SHARING_EXTENSION_NOT_INSTALLED' Screen-sharing support in this browser requires an extension, but the extension is not installed.
'OT_SET_REMOTE_DESCRIPTION_FAILED' The WebRTC connection failed during setDescription.
'OT_STREAM_CREATE_FAILED' Failed to create the stream in the server model.
'OT_TIMEOUT' Could not publish in a reasonable amount of time.
'OT_USER_MEDIA_ACCESS_DENIED' The end-user denied access to screen sharing.
'OT_UNEXPECTED_SERVER_RESPONSE' This indicates an unexpected error from the OpenTok server.

Errors that can occur when calling Session.signal():

name Description
'OT_INVALID_PARAMETER' One or more parameters was not valid or not provided.
'OT_NOT_CONNECTED' Couldn't perform action because you are not connected to the network.
'OT_NOT_FOUND' A resource was not found.
'OT_RATE_LIMIT_EXCEEDED' The signal could not be sent due to the rate limit.

Errors that can occur when calling Session.subscribe():

name Description
'OT_CREATE_PEER_CONNECTION_FAILED' Failed to create a connection between this client and the stream's publisher or the OpenTok Media Router.
'OT_DISCONNECTED' Action failed because the client is not connected to the session.
'OT_INVALID_PARAMETER' One or more parameters was not valid or not provided.
'OT_ICE_WORKFLOW_FAILED' Something went wrong while establishing WebRTC connectivity.
'OT_MEDIA_ERR_ABORTED' The fetching of the stream for the video element has been aborted.
'OT_MEDIA_ERR_DECODE' A decoding error occurred while trying to play the stream in the video element.
'OT_MEDIA_ERR_NETWORK' A network error caused the stream to stop being fetched.
'OT_MEDIA_ERR_SRC_NOT_SUPPORTED' The stream has been detected to be not suitable for playback.
'OT_NOT_CONNECTED' Couldn't perform action because you are not connected to the network.
'OT_SET_REMOTE_DESCRIPTION_FAILED' The WebRTC connection failed during setDescription.
'OT_STREAM_DESTROYED' The stream was destroyed before it could be subscribed to.
'OT_STREAM_NOT_FOUND' Couldn't subscribe to the stream because it was not found.

Errors that can occur when calling Subscriber.getStats():

name Description
'OT_NOT_CONNECTED' Couldn't perform action because you are not connected to the network.

Methods

Name Description
isDefaultPrevented() → {Boolean} Whether the default event behavior has been prevented via a call to preventDefault() (true) or not (false).
preventDefault() Prevents the default behavior associated with the event from taking place.

isDefaultPrevented() → {Boolean}

Whether the default event behavior has been prevented via a call to preventDefault() (true) or not (false). See preventDefault().
Returns:

preventDefault()

Prevents the default behavior associated with the event from taking place.

To see whether an event has a default behavior, check the cancelable property of the event object.

Call the preventDefault() method in the callback function for the event.

The following events have default behaviors: