Error Handling
When you make an API call to access an HMS SDK, the SDK may return error codes. ErrorCodes are usually returned when a problem that cannot be recovered without app intervention has occurred.
These are returned as type='error'
through the notifications interface. The type of notification.data
is HMSException
. Find the HMSException interface here.
Handling Autoplay Error
Most browsers have a restriction on audio autoplay where audio is allowed only if the user has interacted with the page. You can read more about the restrictions here for chrome and safari.
Sample UI for handling autoplay code code
If an autoplay error is received(code=3008), UI can show a popup or a notification with button. Once a user click has happened confirming an interaction point, unblockAudio can be called.
await hmsActions.unblockAudio();
Error Codes
Following are the different error codes that are returned by the SDK. Before returning any error code, SDK retries the errors wherever possible.
Error Code | Cause of the error | Action to be taken |
---|---|---|
1000 | Failed to connect to Websocket - Happens due to network issues or firewall blocking Websocket connections | Mention user to check their network connection and firewall/anti-virus/VPN or try again after some time. |
1003 | Websocket disconnected - Happens due to network issues | Mention user to check their network connection or try again after some time. |
2002 | Invalid Endpoint URL | Check the endpoint provided while calling join on HMSSDK . |
2003 | Endpoint is not reachable | Mention user to check their network connection or try again after some time. |
2004 | Token is not in proper JWT format | The token passed while calling join is not in correct format. Retry getting a new token. |
3000 | Overconstrained error | No Action needed from end user, we will be internally retrying. |
3001 | User denied permission to access capture device at browser level | Ask user to check permission granted to audio/video capture devices in browser(in address bar). |
3002 | Capture Device is not Available | Ask user to check if the audio/video capture device is connected or not. |
3003 | Capture device is in use by some other application | Show notification to user mentioning that the capturing device is used by some other application currently. |
3004 | Lost access to capture device midway | Suggest the user to check connection to their hardware device and try reconnecting. |
3005 | There is no media to return. Please select either video or audio or both. | There is no media to return. Please select either video or audio or both. |
3006 | Cannot enable simulcast when no video settings are provided | Configure video track settings to enable simulcast |
3008 | Browser has throw an autoplay exception | Show notification to user mentioning that the browser blocked autoplay |
3009 | Device unable to satisfy requested media constraints | Reduce media constraints for the role in dashboard or upgrade device hardware. |
3010 | No audio detected from track, indicates problem with device hardware | Notify user to try using a headphone for microphone. |
3011 | System denied permission to access capture device | Ask user to check permission granted to audio/video/screen capture devices in system settings. |
3012 | Current tab is not shared when forceCurrentTab was set to true for screenshare | - |
3013 | An error occurred while playing audio of remote audio tracks | - |
3014 | Selected audio/video device not detected on change | Ask user to check if the audio/video capture device is connected or not. |
3015 | No data published by the audio/video track | Ask user to check if another app is already using the mic or camera and retry after terminating the app |
4001 | Failed to create offer | Ask the user to retry joining |
4002 | Failed to create answer | Ask the user to retry joining |
4003 | Failed to set offer | Ask the user to retry joining |
4004 | Failed to set answer | Ask the user to retry joining |
4005 | ICE Connection Failed due to network issue | Mention user to check their network connection or try again after some time. |
4006 | ICE Connection Disconnected due to network issue | Mention user to check their network connection or try again after some time. |
5001 | Trying to join a room which is already joined | Trying to join an already joined room. |
5002 | Trying to join a room when preview is in progress | Call join action only when room state is "Preview" and not "Connecting". |
6000 | Calling actions when not connected/joined to a room | Call the required action after joining a room. |
6002 | WebRTC Error: Error while renegotiating | We can add check error.message for more info. |
6003 | WebRTC engine is not ready yet | Wait for preview to complete before calling join. |
6008 | Invalid arguments(peer ID, track ID, or others) passed to actions | Check if the corresponding arguments are valid by checking the store when calling the action |
6009 | Trying to join a room when preview is in progress | Call join action only when room state is "Preview" and not "Connecting". |
6010 | navigator.mediaDevices is undefined in insecure contexts served over HTTP protocol | Deploy the app in a secure context with HTTPS protocol. |
6011 | RTCPeerConnection is undefined in browser | Switch/Upgrade browser to WebRTC compatible version/check for browser extension blocking WebRTC. |
6012 | The application does not have access to localStorage | Try joining the link in a normal browser window if using in incognito mode causes this error. Alternatively, allowing cookies and localStorage via browser settings also works in incognito mode |
7001 | Platform Not Supported | The platform is not supported for plugin |
7002 | Plugin Init Failed | Plugin initialization has failed |
7003 | Plugin Processing Failed | Plugin processing failed |
7004 | Plugin Add Already Going on | Plugin add is already in progress |
8001 | Playlist: Invalid action call | Check current playing entry, next entry, previous entry when calling seek/seekTo, playNext, playPrevious. |