Error Handling
When you make an API call to access an HMS SDK, the SDK may return error codes. ErrorCodes are returned when a problem that cannot be recovered without app intervention has occurred.
These are returned as HMSException in the onError callback of the HMSUpdateListner.
Errors that need to be handled
While the number of possible errors is large, the handling is very concise.
The errors for general sdk features are self-explanatory, here we will list only the core handling needed for the join and preview methods. You don't need to handle specific errors, just categories of isTerminal or not.
Here's a typical example of a join method with only the error handling methods:
hmsSDK.join(hmsConfig, object : HMSUpdateListener { override fun onError(error: HMSException) { // Show a different dialog if error is terminal else a dismissible dialog if (error.isTerminal) { // The meeting cannot continue, display the error and return to your previous screen. // 1. Hide the progress bar that you were showing for a join call. // 2. You may choose to give a retry button that will attempt the join again. } else { // The meeting can continue, there may be temporary issues. // The SDK will recover from these automatically. // Only inform the user that it's happening. // 1. `error.message` may be shown to the user. } } // Show UI for temporary disconnections and if the sdk could reconnect. // If there was a permanent failure, it will be sent in `onError`. override fun onReconnecting() {} override fun onReconnected() {} }
Preview
The same handling can be applied for the onError method of the HMSPreviewListener.
Others
Permissions handling has also been simplified and you may look at how to handle those here.
Index
Following are the different error codes that are returned by the SDK . Before returning any error code, SDK retries the errors(whichever is possible).
| Error Code | Cause of the error | Action to be taken |
|---|---|---|
| 1000 | Generic Error | Need to debug further with logs. |
| 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 | Generic Error | Need to debug further with logs. |
| 3001 | Cant Access Capture Device | Ask user to check permission granted to audio/video capture devices. |
| 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 | For building HMSTrackSettings either audio or video track has to be present. |
| 3006 | Invalid Video Settings | Simulcast cannot be started without providing video settings. |
| 3007 | Codec cannot change mid call | Codec cannot be changed mid call. |
| 3011 | Mic Capture Failed | Failed to capture mic access. |
| 3017 | Media Projection Permission Error | Cannot start screen-share, due to FOREGROUND_SERVICE_MEDIA_PROJECTION being absent |
| 4001 | WebRTC error | Some webRTC error has occurred. Need more logs to debug. |
| 4002 | WebRTC error | Some webRTC error has occurred. Need more logs to debug. |
| 4003 | WebRTC error | Some webRTC error has occurred. Need more logs to debug. |
| 4004 | WebRTC error | Some webRTC error has occurred. 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 start Preview which is already started | Trying to start Preview which is already started. |
| 6000 | Client failed to connect | Client failed to connect. |
| 6002 | Unknown | Further debugging needed. |
| 6002 | webRTC Error: Error while renegotiating | Please try again. |
| 6004 | Json parsing failed | Need to debug further with logs. |
| 6008 | Unable to send message | Cannot send message. Peer is null. The SDK must be disconnected from a room. |
| 6010 | API not supported | This API is not support on the current Android Version (Android-31). |
| 6012 | Poll Not Found | getPollResults throws this if the poll for which results are sought is not found |
| 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 |
| 7005 | Bluetooth Sco Connection Failed | Bluetooth headset is either not available or in a processing state. |
| 8001 | Image Capture Exception | An error that can happen during a call to captureImageAtMaxResolution. Details in the message. |
| 9001 | Blur Plugin Exception | Device needs to support OpenGL ES > 3.1 for blur to work. Addtional debugging may be needed. |
| 400 | Error occurred | This can usually happen due to token issues(Check logs for more description). Need more logs to debug. |
| 401 | Error occurred | This can usually happen due to token issues(Check logs for more description). Need more logs to debug. |
| 410 | Peer is gone | The peer is no more present in the room. |
| 500 | Error occurred | This is a general server error(Check logs for more description). Need more logs to debug. |



