100ms Logo

100ms

Docs

Search docs
/

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 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
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.
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 application.Show notification to user mentioning that the capturing device is used by some other application currently.
3012BLUETOOTH_CONNECT permission is not given.Add the BLUETOOTH_CONNECT permission to your app and request it at runtime since it's a dangerous level permission.
3013BLUETOOTH permission is not given.Add the BLUETOOTH permission to your app.
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.
6002webRTC Error: Error while renegotiatingPlease try again.
40101Token Error: Invalid Access KeyAccess Key provided in the token is wrong.
40102Token Error: Invalid Room IdRoomID provided in the token is wrong.
40103Token Error: Invalid Auth IdAuthID provided in the token is wrong.
40104Token Error: Invalid App IdApp ID provided in the token is wrong.
40105Token Error: Invalid Customer IdCustomer Id provided in the token is wrong.
40107Token Error: Invalid User IdUser ID provided in the token is wrong.
40108Token Error: Invalid RoleThe role provided in the token is wrong.
40109Token Error: Bad JWT TokenBad JWT Token.
40100Generic ErrorNeed to debug further with logs.
40001Invalid RoomRoom ID provided while fetching the token is an invalid room.
40002Room Mismatched with TokenRoom ID provided while fetching the token does not match.
40004Peer already joinedPeer who is trying to join has already joined the room.
41001Peer is goneThe peer is no more present in the room.
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

HMSException

The SDK returns 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; }

Terminal Errors

Terminal errors are raised when SDK has cleaned up the connection due to the error. isTerminal property of HMSException object can be used to check whether the error is a terminal error.

💡 Note: isTerminal denotes if the SDK has cleaned up the connection due to the error or not. If this is [true] it denotes that the error has removed user from the room else it denotes that user is still in the room even with the error.

Hence isTerminal property can be used to handle the UI as if isTerminal:true we can navigate user back to home screen or show them a popup. While in other case the error can be handled accrodingly.

Terminal error example:

Terminal Error

Above error(errorCode:1003) occurs when the reconnection fails.The SDK returns this error after trying to reconnect for 60 seconds. In such cases the isTerminal property can be used to handle the UI updates.

🔑 More info on reconnection handling can be found here