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.
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 to due 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. |
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. |
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. |
4001 | WebRTC error | Some webRTC error has occured. Need more logs to debug. |
4002 | WebRTC error | Some webRTC error has occured. Need more logs to debug. |
4003 | WebRTC error | Some webRTC error has occured. Need more logs to debug. |
4004 | WebRTC error | Some webRTC error has occured. Need more logs to debug. |
4005 | ICE Connection Failed 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 extenstion blocking WebRTC. |
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. |