Suggestions

close search

Add Messaging, Voice, and Authentication to your apps with Vonage Communications APIs

Visit the Vonage API Developer Portal

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 Error class also defines the Error thrown when the promise returned by one of the following methods is rejected:

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.

The code property of the Error object can be set to one of the values listed below. This property can also be set to other values, and you may want to report this value when discussing an issue with Vonage API support.

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.
1027 Connection limit exceeded. The client tried to connect to a session that has exceeded limit for simultaneous connections.
2001 Connect Failed. Unexpected response from the OpenTok server. Try connecting again later.

Errors after calling Session.connect():

code Description
3001 - 3007 Please check error name OT_HTTP_ERROR.
4020 Session disconnected. It seems internet connection went down.

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.

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.
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
0009 Media source not supported.
0011 Error decoding.
1013 WebRTC PeerConnection error. Try republishing the stream, resubscribing to the stream, or reconnecting to the session.
1501 Unable to subscribe to stream in a reasonable amount of time.
1502 Video format not supported in this browser.
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.
1605 Stream limit exceeded. The client tried to subscribe to a stream in a session that has exceeded the limit for simultaneous streams.
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.

Errors when calling OT.reportIssue():

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

Errors when calling OT.setProxyUrl():

code Description
2021 Attempt to set the proxy URL after initiating a Session or Publisher object.
2022 Attempt to set the proxy URL after it has already been set (by a previous call to OT.setProxyUrl()).

Errors when calling Publisher.setVideoSource():

code Description
1040 Trying to change the video source for a publisher does not use a camera input.
1041 The videoSourceId parameter is not a string or the device ID for a valid video input device.

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_'.

The name property of the Error object can be set to one of the values listed below. For unexpected errors, this property can be undefined or set to other values. You may want to report this value when discussing an issue with Vonage API support.

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_ENDED' The ended event on the video element fired.
'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_PROXY_URL_ALREADY_SET_ERROR' The proxyUrl has already been set. Setting it again will not have any effect.
'OT_REQUESTED_DEVICE_PERMISSION_DENIED' The requested audio device does not have permissions to be used.
'OT_SCREEN_SHARING_NOT_SUPPORTED' Screen sharing is not supported in the browser.
'OT_UNABLE_TO_CAPTURE_SCREEN' 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.
'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 the OT.setProxyUrl() method:

name Description
'SET_PROXY_URL_TIMING_ERROR' Attempt to set the proxy URL after initiating a Session or Publisher object.
'PROXY_URL_ALREADY_SET_ERROR' Attempt to set the proxy URL after it has already been set (by a previous call to OT.setProxyUrl()).

Errors that can occur when calling Publisher.setVideoSource():

name Description
'OT_INVALID_VIDEO_SOURCE' The videoSourceId parameter is not a string or the device ID for a valid video input device.
'OT_SET_VIDEO_SOURCE_FAILURE' Trying to change the video source for a publisher does not use a camera input.

Errors that can occur when calling 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_CONNECTION_LIMIT_EXCEEDED' The client tried to connect to a session that has exceeded the limit for simultaneous connections.
'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.
'OT_INVALID_ENCRYPTION_SECRET' The encryption secret is invalid.
'OT_UNSUPPORTED_BROWSER' The browser does not support end-to-end encryption.

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.forceMuteAll():

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.
'OT_UNEXPECTED_SERVER_RESPONSE' An internal server error.

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

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' The stream ID wasn't found in this session.
'OT_PERMISSION_DENIED' The token does not allow this action. The role must be at least moderator.
'OT_UNEXPECTED_SERVER_RESPONSE' An internal server error.

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_STREAM_CREATE_FAILED' The user attempted to publish in an end-to-end encryption enabled session without specifying an encryption key.
'OT_ICE_WORKFLOW_FAILED' Something went wrong while establishing WebRTC connectivity.
'OT_INVALID_AUDIO_OUTPUT_SOURCE' Invalid output audio device ID. It must be a valid video output device ID.
'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 permission to access hardware devices, or the end-user denied access to the screen (for a screen-sharing stream).
'OT_UNABLE_TO_CAPTURE_MEDIA' Unable to capture media. Unknown error occurred.
'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_UNABLE_TO_SUBSCRIBE' The user attempted to subscribe in an end-to-end encryption enabled session without having specified an encryption secret.
'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_LIMIT_EXCEEDED' The client tried to subscribe to a stream in a session that has exceeded the limit for simultaneous streams.
'OT_STREAM_NOT_FOUND' Couldn't subscribe to the stream because it was not found.
'OT_UNABLE_TO_SUBSCRIBE' Couldn't subscribe to stream due to unexpected error.

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

name Description
'OT_HTTP_ERROR' Action failed. Received invalid response from the OpenTok server.
'OT_NOT_CONNECTED' Couldn't perform action because you are not connected to the network.

Errors that can occur when the Promise returned by the OT.unblockAudio() method is rejected:

name Description
'OT_MEDIA_ERR_ABORTED' The fetching of an audio stream has been aborted.
'OT_MEDIA_ERR_NETWORK' A network error caused a stream to stop being fetched.
'OT_MEDIA_ERR_DECODE' A decoding error occurred while trying to play a stream.
'OT_MEDIA_ERR_SRC_NOT_SUPPORTED' A stream has been detected to be not suitable for playback.

Errors that can occur when the Promise returned by the Publisher.getRtcStatsReport() or Subscriber.getRtcStatsReport() method is rejected:

name Description
'OT_PEER_CONNECTION_NOT_CONNECTED' The PeerConnection for the Publisher or Subscriber is not connected.
'OT_GET_RTC_STATS_REPORT_NOT_SUPPORTED' The browser does not support this method (for example, in Chrome version 57 and lower, which does not support the RTCPeerConnection.getStats() standard).

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: