Error Handling

When you make an API call to access an HMS SDK, the SDK may return error codes. Error codes are returned when a problem that cannot be recovered without app intervention has occurred.

These are returned as HMSException in the onHMSError callback of the HMSUpdateListener.

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 CodeCause of the errorAction to be taken
1000Generic ErrorNeed to debug further with logs.
1003Websocket disconnected - Happens due to network issuesMention user to check their network connection or try again after some time.
2002Invalid Endpoint URLCheck the endpoint provided while calling join on HMSSDK.
2003Endpoint is not reachableMention user to check their network connection or try again after some time.
2004Token is not in proper JWT formatThe token passed while calling join is not in correct format. Retry getting a new token.
3000Generic ErrorNeed to debug further with logs.
3001Cant Access Capture DeviceAsk user to check permission granted to audio/video capture devices.
3002Capture Device is not AvailableAsk user to check if the audio/video capture device is connected or not.
3003Capture device is in use by some other applicationShow notification to user mentioning that the capturing device is used by some other application currently.
3005There is no media to returnFor building HMSTrackSettings either audio or video track has to be present.
3006Invalid Video SettingsSimulcast cannot be started without providing video settings.
3007Codec cannot change mid callCodec cannot be changed mid call.
3011Mic Capture FailedFailed to capture mic access.
3017Media Projection Permission ErrorCannot start screen-share, due to FOREGROUND_SERVICE_MEDIA_PROJECTION being absent
4001WebRTC errorSome webRTC error has occurred. Need more logs to debug.
4002WebRTC errorSome webRTC error has occurred. Need more logs to debug.
4003WebRTC errorSome webRTC error has occurred. Need more logs to debug.
4004WebRTC errorSome webRTC error has occurred. Need more logs to debug.
4005ICE Connection Failed due to network issueMention user to check their network connection or try again after some time.
5001Trying to join a room which is already joinedTrying to join an already joined room.
5002Trying to start Preview which is already startedTrying to start Preview which is already started.
6000Client failed to connectClient failed to connect.
6002webRTC Error: Error while renegotiatingPlease try again.
6004Json parsing failedNeed to debug further with logs.
6008Unable to send messageCannot send message. Peer is null. The SDK must be disconnected from a room.
6010API not supportedThis API is not support on the current Android Version (Android-31).
6012Poll Not FoundgetPollResults throws this if the poll for which results are sought is not found
7001Platform Not SupportedThe platform is not supported for plugin
7002Plugin Init FailedPlugin initialization has failed
7003Plugin Processing FailedPlugin processing failed
7004Plugin Add Already Going onPlugin add is already in progress
7005Bluetooth Sco Connection FailedBluetooth headset is either not available or in a processing state.
8001Image Capture ExceptionAn error that can happen during a call to captureImageAtMaxResolution. Details in the message.
9001Blur Plugin ExceptionDevice needs to support OpenGL ES > 3.1 for blur to work. Addtional debugging may be needed.
400Error occurredThis can usually happen due to token issues(Check logs for more description). Need more logs to debug.
401Error occurredThis can usually happen due to token issues(Check logs for more description). Need more logs to debug.
410Peer is goneThe peer is no more present in the room.
500Error occurredThis is a general server error(Check logs for more description). Need more logs to debug.

HMSException

The SDK returns an error as an object of HMSException in onHMSError method.

void onHMSError({required HMSException error}){ //Handle Error }

Let's have a look at the HMSException object

class HMSException { final String? id; //HMSException code final HMSExceptionCode? code; //Error message final String message; //Error description String description; //Action in which SDK failed String action; //Extra params sent with the error Map? params; //Whether the error is a terminal error or not bool isTerminal; }

Setting log levels in SDK (Android Only)

100ms provides ability to save logs to disk on Android devices. These logs can be used to diagnose performance of room sessions. By default, logging is disabled, that is, set to HMSLogLevel.OFF. To enable logging, create the HMSLogSettings object & pass it while constructing the HMSSDK instance. This functionality of saving logs to Disk is not available on iOS.

// Create the Log Settings object HMSLogSettings hmsLogSettings = HMSLogSettings( maxDirSizeInBytes: 1000000, isLogStorageEnabled: true, level: HMSLogLevel.VERBOSE); hmsSDK = HMSSDK( hmsLogSettings: hmsLogSettings); // pass the Log Settings as a parameter while constructing the HMSSDK instance

HMSLogLevel is an enum with values:

enum HMSLogLevel { //To receive all the logs VERBOSE, //To receive warnings WARN, //To receive errors ERROR, //To turn OFF logs from SDK OFF, Unknown }

Have a suggestion? Recommend changes ->

Was this helpful?

1234