Once you enable the Primary/Secondary certificate and the No certificate does not exist in your project, you have decided that your app authenticates its users with the dynamic token.
Tokens expire. During the runtime of your app, you may receive the following error codes or callback events that are related to the token. This article helps you to learn more about the issues, their causes, and how to troubleshoot.
Issue description:
ERR_INVALID_APP_ID(101)
when initializing the Agora service, or reports the ERR_INVALID_APP_ID(101)
error in the onError
callback when you try to join a channel by calling joinChannel
.ERR_INVALID_VENDOR_KEY(101)
when the SDK initializes the Agora service, or when you try to join a channel by calling Client.join
.Reason: The App ID is invalid, usually because the data format of the App ID is incorrect.
Solution: Check the data format of your App ID. Ensure that you use the correct App ID to initialize the Agora service.
Issue description:
ERR_TOKEN_EXPIRED(109)
error in the onError
callback when you try to join a channel by calling joinChannel
.ERR_DYNAMIC_KEY_TIMEOUT(109)
or ERR_DYNAMIC_KEY_EXPIRED(118)
when you try to join a channel by calling Client.join
.Reason: The token has expired.
Solution: When a token expires, you need to generate a new token on your server, and try to join the channel by calling renewToken
.
Issue description:
ERR_INVALID_TOKEN(110)
in the onError callback when you try to join a channel by calling joinChannel
.ERR_NO_AUTHORIZED(110)
when you try to to join a channel by calling Client.join
.Reason: The token is invalid, usually for the following reasons:
Solution:
Issue description: The Console prints ERR_STATIC_USE_DYNAMIC_KEY(119)
when the SDK tries to join a channel by calling Client.join.
Reason: This is because you try to join a channel with a token in a situation where the Agora project has not enabled the Primary/Secondary certificate. You can use a token to join a channel only when the Primary/Secondary certificate is enabled.
Solution: For projects that have not enabled the Primary/Secondary certificate, you can either join a channel without a token, or enable the Primary/Secondary certificate, generate a token on your server, and join a channel using that token.
Issue description: The Console prints ERR_DYNAMIC_USE_STATIC_KEY(120)
when you try to join a channel by calling Client.join.
Reason: This is because you fail to provide a token when joining a channel in the situation where you has enabled the Primary/Secondary certificate and the No certificate does not exist in your project.
Solution: If you has enabled the Primary/Secondary certificate and the No certificate does not exist in your project, you must provide a token when joining a channel. You can also initialize the Agora service with an App ID that has not enabled the Primary/Secondary certificate.
To ensure smooth communication, Agora provides the following two callback events to remind the user that the token is about to expire, or has expired.
onTokenPrivilegeWillExpire
: Occurs 30 seconds before the token expires. Upon receiving this callback, generate a new token on the server, and call renewToken to pass the new token to the SDK.onRequestToken
(or onTokenPrivilegeDidExpire
on Web): Occurs when the token expires. Upon receiving this callback, generate a new token on the server, call joinChannel
, and pass the new token to join the channel.Error code | Java/C++/C# | Objective-C | Javascript |
---|---|---|---|
101 | ERR_INVALID_APP_ID |
AgoraErrorCodeInvalidAppId |
ERR_INVALID_VENDOR_KEY |
109 | ERR_TOKEN_EXPIRED |
AgoraErrorCodeTokenExpired |
ERR_DYNAMIC_KEY_TIMEOUT |
110 | ERR_INVALID_TOKEN |
AgoraErrorCodeInvalidToken |
ERR_NO_AUTHORIZED |
2 | / | / | K_TIMESTAMP_EXPIRED |
118 | / | / | ERR_DYNAMIC_KEY_EXPIRED |
119 | / | / | ERR_STATIC_USE_DYNAMIC_KEY |
120 | / | / | ERR_DYNAMIC_USE_STATIC_KEY |