# 错误排查 (/zh-CN/realtime-media/rtm/build/troubleshooting/react-native)
> For AI agents: see the complete documentation index at [llms.txt](/llms.txt).
在调用 RTM React Native API 时,如果发生错误,SDK 会抛出一个 `ErrorInfo` 类型数据,包含以下属性:
```typescript
type ErrorInfo = {
error: boolean; // 本次操作是否出错
reason: string; // 本次操作的 API 名称
operation: string; // 错误码
errorCode: number; // 错误描述
};
```
其中,`errorCode` 和 `reason` 属性分别报告错误码和错误描述,你可以在下面的表格中寻找解决方法:
| 错误码 | 错误描述 | 原因及解决方法 |
| --- | --- | --- |
| `0` | `ok` | 正确调用。 |
| `-10002` | `notLogin` | 用户未登录 RTM 系统、掉线超时或者主动退出登录后调用 API。请先登录 RTM 系统。 |
| `-10003` | `invalidAppId` | [error-codes-rn-html-0-3-2 details](#table-slot-error-codes-rn-html-0-3-2) |
| `-10004` | `invalidEventHandler` | 无效的 Event Handler。 |
| `-10005` | `invalidToken` | 无效 Token。检查 Token Provider 是否生成 RTM Token。 |
| `-10006` | `invalidUserId` | [error-codes-rn-html-0-6-2 details](#table-slot-error-codes-rn-html-0-6-2) |
| `-10008` | `invalidChannelName` | [error-codes-rn-html-0-7-2 details](#table-slot-error-codes-rn-html-0-7-2) |
| `-10009` | `tokenExpired` | Token 过期失效。你需要先调用 `logout` 方法登出 RTM 系统,然后使用新的 Token 创建 RTM 实例,再调用 `login` 方法重新登录 RTM 系统。 |
| `-10010` | `loginNoServerResources` | 服务器资源受限。建议重新登录。 |
| `-10011` | `loginTimeout` | 登录超时。你需要检查当前网络是否稳定并切换到稳定网络环境中。如果你的网络处于内网环境,请检查你的防火墙是否配置了正确的域名和端口。 |
| `-10012` | l`oginRejected` | [error-codes-rn-html-0-11-2 details](#table-slot-error-codes-rn-html-0-11-2) |
| `-10013` | `loginAborted` | [error-codes-rn-html-0-12-2 details](#table-slot-error-codes-rn-html-0-12-2) |
| `-10015` | `loginNotAuthorized` | [error-codes-rn-html-0-13-2 details](#table-slot-error-codes-rn-html-0-13-2) |
| `-10016` | `inconsistentAppid` | 登录或加入频道时使用的 App ID 不一致。 |
| `-10017` | `duplicateOperation` | 重复操作。 |
| `-10018` | `instanceAlreadyReleased` | 重复释放 `RTMClient` 实例或 `RTMStreamChannel` 实例。 |
| `-10019` | `invalidChannelType` | [error-codes-rn-html-0-17-2 details](#table-slot-error-codes-rn-html-0-17-2) |
| `-10020` | `invalidEncryptionParameter` | [error-codes-rn-html-0-18-2 details](#table-slot-error-codes-rn-html-0-18-2) |
| `-10021` | `operationRateExceedLimitation` | Channel Metadata 或 User Metadata 相关 API 的调用频率超限。请控制调用频率在 10 次/秒之内。 |
| `-10022` | `serviceNotSupported` | 服务类型不支持。请检查你在 `RtmServiceType` 中设置的服务类型是否正确。该错误码仅适用于私有化部署功能。 |
| `-10023` | `loginCanceled` | [error-codes-rn-html-0-21-2 details](#table-slot-error-codes-rn-html-0-21-2) |
| `-10025` | `notConnected` | 未连接 RTM 服务器。在调用消息订阅、Metadata 或 Lock 模块相关 API 时,如果 RTM 服务未连接,会报这个错误。 |
| `-10026` | `renewTokenTimeout` | 更新 Token 超时。 |
| `-11001` | `channelNotJoined` | [error-codes-rn-html-0-24-2 details](#table-slot-error-codes-rn-html-0-24-2) |
| `-11002` | `channelNotSubscribed` | [error-codes-rn-html-0-25-2 details](#table-slot-error-codes-rn-html-0-25-2) |
| `-11003` | `channelExceedTopicUserLimitation` | 订阅该 Topic 人数超出限制。 |
| `-11005` | `channelInstanceExceedLimitation` | 创建的频道数量或订阅的频道数量超出限制。 |
| `-11006` | `channelInErrorState` | 频道不可用。请重新创建 Stream Channel 或重新订阅 Message Channel。 |
| `-11007` | `channelJoinFailed` | [error-codes-rn-html-0-29-2 details](#table-slot-error-codes-rn-html-0-29-2) |
| `-11008` | `channelInvalidTopicName` | [error-codes-rn-html-0-30-2 details](#table-slot-error-codes-rn-html-0-30-2) |
| `-11009` | `channelInvalidMessage` | 无效消息。检查消息类型是否合法,RTM 只支持字符串或二进制类型消息。 |
| `-11010` | `channelMessageLengthExceedLimitation` | [error-codes-rn-html-0-32-2 details](#table-slot-error-codes-rn-html-0-32-2) |
| `-11012` | `channelNotAvailable` | Stream Channel 功能未开通,当前不可用。检查控制台是否已开启 Stream Channel 功能。 |
| `-11013` | `channelTopicNotSubscribed` | 未订阅该 Topic。 |
| `-11014` | `channelExceedTopicLimitation` | Topic 数量超出限制。 |
| `-11015` | `channelJoinTopicFailed` | 加入该 Topic 失败。检查已加入 Topic 数量是否超出限制。 |
| `-11016` | `channelTopicNotJoined` | 未加入该 Topic。未加入 Topic 就发送消息,你需要先加入 Topic。 |
| `-11017` | `channelTopicNotExist` | 该 Topic 不存在。检查 Topic 名是否错误。 |
| `-11018` | `channelInvalidTopicMeta` | Topic 中的 `meta` 参数无效。检查 `meta` 参数是否超出 256 字节的限制。 |
| `-11019` | `channelSubscribeTimeout` | 频道订阅超时。检查连接是否断开。 |
| `-11020` | `channelSubscribeTooFrequent` | 频道订阅操作太频繁。请确保 5 秒内对同一频道的订阅操作不超过 2 次。 |
| `-11021` | `channelSubscribeFailed` | 频道订阅失败。检查已订阅频道数量是否超出限制。 |
| `-11023` | `channelEncryptMessageFailed` | [error-codes-rn-html-0-43-2 details](#table-slot-error-codes-rn-html-0-43-2) |
| `-11024` | `channelPublishMessageFailed` | 消息发布失败。检查连接是否断开。 |
| `-11026` | `channelPublishMessageTimeout` | 消息发布超时。检查连接是否断开。 |
| `-11028` | `channelLeaveFailed` | 离开频道失败。检查连接是否断开。 |
| `-11029` | `channelCustomTypeLengthOverflow` | Custom type 长度溢出。`customType` 字段长度需要在 32 个字符以内。 |
| `-11030` | `channelInvalidCustomType` | `customType` 字段无效。检查 `customType` 字段是否包含非法字符。 |
| `-11033` | `channelReceiverOffline` | [error-codes-rn-html-0-49-2 details](#table-slot-error-codes-rn-html-0-49-2) |
| `-12001` | `storageOperationFailed` | Storage 操作失败。 |
| `-12002` | `storageMetadataItemExceedLimitation` | Storage Metadata Item 数量超出限制。 |
| `-12003` | `storageInvalidMetadataItem` | 无效 Metadata Item。 |
| `-12004` | `storageInvalidArgument` | 无效参数。 |
| `-12005` | `storageInvalidRevision` | 无效 Revision 参数。 |
| `-12006` | `storageMetadataLengthOverflow` | Metadata 长度溢出。 |
| `-12007` | `storageInvalidLockName` | 无效 Lock 名称。 |
| `-12008` | `storageLockNotAcquired` | 未获取该 Lock。 |
| `-12009` | `storageInvalidKey` | 无效 Metadata 键。 |
| `-12010` | `storageInvalidValue` | 无效 Metadata 值。 |
| `-12011` | `storageKeyLengthOverflow` | Metadata 键长度溢出。 |
| `-12012` | `storageValueLengthOverflow` | Metadata 值长度溢出。 |
| `-12014` | `storageOutdatedRevision` | 过时的 Revision 参数。 |
| `-12015` | `storageNotSubscribe` | 未订阅该频道。 |
| `-12017` | `storageSubscribeUserExceedLimitation` | 订阅用户 Metadata 数量超出限制。 |
| `-12018` | `storageOperationTimeout` | Storage 操作超时。 |
| `-12019` | `storageNotAvailable` | Storage 服务不可用。 |
| `-13001` | `presenceNotConnected` | 用户未连接到系统。 |
| `-13003` | `presenceInvalidArgument` | 无效参数。 |
| `-13004` | `presenceCachedTooManyStates` | 加入频道前缓存的临时用户状态超出限制。 |
| `-13005` | `presenceStateCountOverflow` | 临时用户状态键/值对数量超出限制。 |
| `-13006` | `presenceInvalidStateKey` | 无效状态键。 |
| `-13008` | `presenceStateKeySizeOverflow` | 状态键长度溢出。 |
| `-13010` | `presenceStateDuplicateKey` | 重复的状态键。 |
| `-13009` | `presenceStateValueSizeOverflow` | 状态值长度溢出 |
| `-13011` | `presenceUserNotExist` | 该用户不存在。 |
| `-13012` | `presenceOperationTimeout` | Presence 操作超时。 |
| `-13013` | `presenceOperationFailed` | Presence 操作失败。 |
| `-14001` | `lockOperationFailed` | Lock 操作失败。 |
| `-14002` | `lockOperationTimeout` | Lock 操作超时。 |
| `-14003` | `lockOperationPerforming` | Lock 操作进行中。 |
| `-14004` | `lockAlreadyExist` | Lock 已存在。 |
| `-14005` | `lockInvalidName` | 无效 Lock 名。 |
| `-14006` | `lockNotAcquired` | 未获取该 Lock。 |
| `-14007` | `lockAcquireFailed` | 获取该 Lock 失败。 |
| `-14008` | `lockNotExist` | 该 Lock 不存在。 |
| `-14009` | `lockNotAvailable` | Lock 服务不可用。 |
| `-15001` | `historyOperationFailed` | 历史消息的操作失败。 |
| `-15003` | historyOperationTimeout | 历史消息操作过时。 |
| `-15005` | `historyNotAvailable` | 历史消息服务不可用。 |
**error-codes-rn-html-0-3-2 details**
无效 App ID:
- 检查 App ID 是否错误。
- 检查 App ID 是否开通了 RTM 服务。
**error-codes-rn-html-0-6-2 details**
无效用户 ID:
- 检查用户名是否为空。
- 检查用户名是否包含非法字符。
**error-codes-rn-html-0-7-2 details**
无效频道名称:
- 检查频道名是否为空。
- 检查频道名是否包含非法字符。
**error-codes-rn-html-0-11-2 details**
SDK 被服务器拒绝登录:
- 检查 App ID 是否开通 RTM 服务。
- 检查 Token 或 `userId` 是否被封禁。
**error-codes-rn-html-0-12-2 details**
由于未知问题 SDK 登录中断:
- 检查当前网络是否稳定,切换到稳定网络环境中。
- 当前 `userId` 在其他端登录。
**error-codes-rn-html-0-13-2 details**
没有 RTM 服务权限。可能的原因有:
- 未在控制台启用 RTM 服务。
- 服务已欠费。
- 账号被封停。
**error-codes-rn-html-0-17-2 details**
频道类型无效。SDK 仅支持如下频道类型,请填写正确的值:
- `MESSAGE`: Message Channel
- `STREAM`: Stream Channel
- `USER`: User Channel
**error-codes-rn-html-0-18-2 details**
消息加密参数无效。
- 检查生成的加密密钥是否为 String 型。
- 检查生成的加密盐是否为 Uint8Array 型,长度是否为 32 字节。
- 检查加密方式与加密密钥、加密盐是否匹配。
**error-codes-rn-html-0-21-2 details**
登录操作已取消。可能原因如下:
- 调用 `login` 方法后,如果你在收到调用结果之前再次调用该方法,则前一次的调用操作会被取消,SDK 会执行后一次的调用。
- 还未成功登录就调用 `logout` 方法登出。
**error-codes-rn-html-0-24-2 details**
用户未加入该频道:
- 用户不在线、已离线或未加入该频道
- 检查 `userId` 是否拼写错误。
**error-codes-rn-html-0-25-2 details**
用户未订阅该频道:
- 用户不在线、已离线或未加入该频道
- 检查 `userId` 是否拼写错误。
**error-codes-rn-html-0-29-2 details**
加入该频道失败:
- 检查已加入频道数量是否超限。
- 检查频道名是否非法。
- 检查网络是否断开连接。
**error-codes-rn-html-0-30-2 details**
无效 Topic 名:
- 检查 Topic 名是否包含非法字符。
- 检查 Topic 名是否为空。
**error-codes-rn-html-0-32-2 details**
消息长度超出限制。检查消息负载大小是否超限:
- Message Channel 单个消息包小于 32 KB。
- Stream Channel 单个消息包小于 1 KB。
**error-codes-rn-html-0-43-2 details**
消息加密失败:
- 检查加密密钥是否有效。
- 检查加密盐是否有效。
- 检查加密方式与加密密钥、加密盐是否匹配。
**error-codes-rn-html-0-49-2 details**
发送用户消息时,远端用户不在线:
- 检查在调用方法时设置的用户 ID 是否正确。
- 检查远端用户是否登录系统并处于在线状态。
如果以上措施都为未能解决你的故障,或者你需要解决方案的支持,请将你的需求整理出来并通过邮箱发送到:rtm-support@agora.io。我们会在收到邮件的第一时间与你取得联系。