How to handle Token-related error codes in Express?
Since Token has a certain validity period, during the application runtime, you may receive some error codes or event callbacks related to Token. For common error codes and event callbacks, this article provides the reasons for triggering and recommended handling methods to help developers locate and troubleshoot problems.
You can verify the correctness of the Token generated by your server on the ZEGOCLOUD Console. For details, please refer to Console - Development Assistance - Temporary Token Generation and Token Verification.
Precautions
30 seconds before the Token expires, the SDK will send a notification through the onRoomTokenWillExpire callback. After receiving this callback, developers need to obtain a new valid Token from their own server and call the renewToken interface provided by the SDK to update the Token. If not handled, different versions have different mechanisms for handling Token expiration:
-
If you are using ZEGO Express SDK version 2.8.0 to 2.12.0, if the Token is not updated when the permission expires:
- Users already logged into the room will not be kicked out.
- Users who have successfully logged into the room will not be affected by publishing and playing streams, but it will affect the user's next publishing and playing operations.
-
If you are using ZEGO Express SDK version 2.13.0 or above:
-
You can contact ZEGOCLOUD Technical Support to configure the permission expiration management mechanism. If the Token is not updated when the permission expires:
- Users already logged into the room will be kicked out and cannot log in again.
- Users who have successfully logged into the room will have their publishing stopped and cannot perform the next publishing.
-
If you do not contact ZEGOCLOUD Technical Support to configure the permission expiration management mechanism, if the Token is not updated:
- Users already logged into the room will not be kicked out.
- Users who have successfully logged into the room will not be affected by publishing and playing streams, but it will affect the user's next publishing and playing operations.
-
Native Platform
Native platform mainly refers to Android, iOS, macOS, and Windows platforms.
Error Codes
| Error Code | Description |
|---|---|
| 1002033 | Room login authentication failed. |
Event Callbacks
onRoomTokenWillExpire: Callback notification that room Token authentication is about to expire, sent 30 seconds before Token expiration. When this callback is received, you can use the renewToken interface to update the Token. If not updated, it will affect the user's next login and publishing operations, but will not affect current operations.
API Reference:
- iOS: onRoomTokenWillExpire, renewToken
- Android: onRoomTokenWillExpire, renewToken
- macOS: onRoomTokenWillExpire, renewToken
- Windows: onRoomTokenWillExpire, renewToken
Web Platform
Error Codes
| Error Code | Description | Handling Suggestion |
|---|---|---|
| 1102016 | Login Token error. | You can refer to Using Token Authentication to generate the correct Token. |
| 1102018 | Login Token timeout. | When the Token expires, developers need to obtain a new valid Token from their own server and call the renewToken interface provided by the SDK to update the Token. |
