Skip to content

状态码

共有两种状态码需要开发者了解,一种是ResponseStatusCode,另一种是SessionCloseStatus。下表内容不需要刻意记忆,只需要在遇见不认识的状态码时,懂得查询即可。

ResponseStatusCode

ResponseStatusCode表明请求响应中的处理状态,类似HTTP的状态码。

每一个请求响应都会包含一个ResponseStatusCode。具体的状态码声明可查阅turms-client-kotlin项目下的im.turms.client.model.ResponseStatusCode类。

客户端独有状态码

客户端独有状态码不会出现在Turms服务端中,表明客户端请求在客户端本地就被拒绝执行。

类别名称状态码含义
连接相关CONNECT_TIMEOUT1
请求相关INVALID_REQUEST100
CLIENT_REQUESTS_TOO_FREQUENT101
REQUEST_TIMEOUT102
ILLEGAL_ARGUMENT103
通知相关INVALID_NOTIFICATION200
INVALID_RESPONSE201
会话相关CLIENT_SESSION_ALREADY_ESTABLISHED300
CLIENT_SESSION_HAS_BEEN_CLOSED301
消息相关MESSAGE_IS_REJECTED400
存储相关QUERY_PROFILE_URL_TO_UPDATE_BEFORE_LOGIN500

通用状态码

类别名称状态码含义
成功响应OK1000
NO_CONTENT1001
ALREADY_UP_TO_DATE1002
客户端请求错误INVALID_REQUEST1100
CLIENT_REQUESTS_TOO_FREQUENT1101
ILLEGAL_ARGUMENT1102
RECORD_CONTAINS_DUPLICATE_KEY1103
REQUESTED_RECORDS_TOO_MANY1104
SEND_REQUEST_FROM_NONEXISTENT_SESSION1105
UNAUTHORIZED_REQUEST1106
服务端错误SERVER_INTERNAL_ERROR1200
SERVER_UNAVAILABLE1201
管理员接口 - 通用错误UNAUTHORIZED1300
NO_FILTER_FOR_DELETE_OPERATION1301
RESOURCE_NOT_FOUND1302
DUPLICATE_RESOURCE1303
ADMIN_REQUESTS_TOO_FREQUENT1304
管理员接口 - JFR相关错误DUMP_JFR_IN_ILLEGAL_STATUS1310
管理员接口 - 插件相关错误JAVASCRIPT_PLUGIN_IS_DISABLED1320
SAVING_JAVA_PLUGIN_IS_DISABLED1321
SAVING_JAVASCRIPT_PLUGIN_IS_DISABLED1322
管理员接口 - 封禁相关错误IP_BLOCKLIST_IS_DISABLED1400
USER_ID_BLOCKLIST_IS_DISABLED1401
管理员接口 - 集群 - 主节点相关错误NONEXISTENT_MEMBER_TO_BE_LEADER1800
NO_QUALIFIED_MEMBER_TO_BE_LEADER1801
NOT_QUALIFIED_MEMBER_TO_BE_LEADER1802
用户 - 登陆相关错误UNSUPPORTED_CLIENT_VERSION2000
LOGIN_TIMEOUT2010
LOGIN_AUTHENTICATION_FAILED2011
LOGGING_IN_USER_NOT_ACTIVE2012
LOGIN_FROM_FORBIDDEN_DEVICE_TYPE2013
用户 - 会话相关错误SESSION_SIMULTANEOUS_CONFLICTS_DECLINE2100
SESSION_SIMULTANEOUS_CONFLICTS_NOTIFY2101
SESSION_SIMULTANEOUS_CONFLICTS_OFFLINE2102
CREATE_EXISTING_SESSION2103
UPDATE_HEARTBEAT_OF_NONEXISTENT_SESSION2104
用户 - 位置相关错误USER_LOCATION_RELATED_FEATURES_ARE_DISABLED2200
QUERYING_NEAREST_USERS_BY_SESSION_ID_IS_DISABLED2201
用户 - 信息相关错误UPDATE_INFO_OF_NONEXISTENT_USER2300
NOT_FRIEND_TO_QUERY_USER_PROFILE2301
BLOCKED_USER_TO_QUERY_USER_PROFILE2302
用户 - 权限组相关错误QUERY_PERMISSION_OF_NONEXISTENT_USER2400
用户 - 关系相关错误ADD_NON_RELATED_USER_TO_GROUP2500
CREATE_EXISTING_RELATIONSHIP2501
CANNOT_BLOCK_ONESELF2502
用户 - 好友请求相关错误CREATE_EXISTING_FRIEND_REQUEST2600
BLOCKED_USER_TO_SEND_FRIEND_REQUEST2601
RECALL_NON_PENDING_FRIEND_REQUEST2602
RECALLING_FRIEND_REQUEST_IS_DISABLED2603
NOT_SENDER_TO_RECALL_FRIEND_REQUEST2604
UPDATE_NON_PENDING_FRIEND_REQUEST2605
NOT_RECIPIENT_TO_UPDATE_FRIEND_REQUEST2606
群组 - 信息相关错误UPDATE_INFO_OF_NONEXISTENT_GROUP3000
NOT_GROUP_OWNER_TO_UPDATE_GROUP_INFO3001
NOT_GROUP_OWNER_OR_MANAGER_TO_UPDATE_GROUP_INFO3002
NOT_GROUP_MEMBER_TO_UPDATE_GROUP_INFO3003
群组 - 类型相关错误NO_PERMISSION_TO_CREATE_GROUP_WITH_GROUP_TYPE3100
CREATE_GROUP_WITH_NONEXISTENT_GROUP_TYPE3101
UPDATING_GROUP_TYPE_IS_DISABLED3102
NOT_GROUP_OWNER_TO_UPDATE_GROUP_TYPE3103
NO_PERMISSION_TO_UPDATE_GROUP_TO_GROUP_TYPE3104
UPDATE_GROUP_TO_NONEXISTENT_GROUP_TYPE3105
群组 - 所有权相关错误NOT_ACTIVE_USER_TO_CREATE_GROUP3200
NOT_GROUP_OWNER_TO_TRANSFER_GROUP3201
NOT_GROUP_OWNER_TO_DELETE_GROUP3202
GROUP_SUCCESSOR_NOT_GROUP_MEMBER3203
GROUP_OWNER_QUIT_WITHOUT_SPECIFYING_SUCCESSOR3204
MAX_OWNED_GROUPS_REACHED3205
TRANSFER_NONEXISTENT_GROUP3206
群组 - 入群问题相关错误NOT_GROUP_OWNER_OR_MANAGER_TO_CREATE_GROUP_QUESTION3300
NOT_GROUP_OWNER_OR_MANAGER_TO_DELETE_GROUP_QUESTION3301
NOT_GROUP_OWNER_OR_MANAGER_TO_UPDATE_GROUP_QUESTION3302
NOT_GROUP_OWNER_OR_MANAGER_TO_QUERY_GROUP_QUESTION_ANSWER3303
CREATE_GROUP_QUESTION_FOR_INACTIVE_GROUP3304
CREATE_GROUP_QUESTION_FOR_GROUP_USING_JOIN_REQUEST3305
CREATE_GROUP_QUESTION_FOR_GROUP_USING_INVITATION3306
CREATE_GROUP_QUESTION_FOR_GROUP_USING_MEMBERSHIP_REQUEST3307
GROUP_QUESTION_ANSWERER_HAS_BEEN_BLOCKED3308
GROUP_MEMBER_ANSWER_GROUP_QUESTION3309
ANSWER_INACTIVE_GROUP_QUESTION3310
ANSWER_GROUP_QUESTION_OF_INACTIVE_GROUP3311
群组 - 成员相关错误ADD_USER_TO_GROUP_REQUIRING_USERS_APPROVAL3400
ADD_USER_TO_INACTIVE_GROUP3401
NOT_GROUP_OWNER_TO_ADD_GROUP_MANAGER3402
ADD_USER_TO_GROUP_WITH_SIZE_LIMIT_REACHED3403
ADD_BLOCKED_USER_TO_GROUP3404
NOT_GROUP_OWNER_TO_ADD_GROUP_MEMBER3405
NOT_GROUP_OWNER_OR_MANAGER_TO_ADD_GROUP_MEMBER3406
NOT_GROUP_MEMBER_TO_ADD_GROUP_MEMBER3407
NOT_GROUP_OWNER_OR_MANAGER_TO_REMOVE_GROUP_MEMBER3408
NOT_GROUP_OWNER_TO_REMOVE_GROUP_OWNER_OR_MANAGER3409
NOT_GROUP_OWNER_TO_UPDATE_GROUP_MEMBER_ROLE3410
UPDATE_GROUP_MEMBER_ROLE_OF_NONEXISTENT_GROUP3411
NOT_GROUP_OWNER_TO_UPDATE_GROUP_MEMBER_INFO3412
NOT_GROUP_OWNER_OR_MANAGER_TO_UPDATE_GROUP_MEMBER_INFO3413
NOT_GROUP_MEMBER_TO_UPDATE_GROUP_MEMBER_INFO3414
UPDATE_GROUP_MEMBER_INFO_OF_NONEXISTENT_GROUP3415
UPDATE_INFO_OF_NONEXISTENT_GROUP_MEMBER3416
NOT_GROUP_OWNER_OR_MANAGER_TO_MUTE_GROUP_MEMBER3417
MUTE_GROUP_MEMBER_WITH_ROLE_EQUAL_TO_OR_HIGHER_THAN_REQUESTER3418
MUTE_GROUP_MEMBER_OF_NONEXISTENT_GROUP3419
MUTE_NONEXISTENT_GROUP_MEMBER3420
NOT_GROUP_MEMBER_TO_QUERY_GROUP_MEMBER_INFO3421
USER_JOIN_GROUP_WITHOUT_ACCEPTING_GROUP_INVITATION3422
USER_JOIN_GROUP_WITHOUT_ANSWERING_GROUP_QUESTION3423
USER_JOIN_GROUP_WITHOUT_SENDING_GROUP_JOIN_REQUEST3424
群组 - 黑名单相关错误NOT_GROUP_OWNER_OR_MANAGER_TO_ADD_BLOCKED_USER3500
NOT_GROUP_OWNER_OR_MANAGER_TO_REMOVE_BLOCKED_USER3501
群组 - 入群请求相关错误BLOCKED_USER_SEND_GROUP_JOIN_REQUEST3600
GROUP_MEMBER_SEND_GROUP_JOIN_REQUEST3601
NOT_SENDER_TO_RECALL_GROUP_JOIN_REQUEST3602
NOT_GROUP_OWNER_OR_MANAGER_TO_QUERY_GROUP_JOIN_REQUEST3603
RECALL_NON_PENDING_GROUP_JOIN_REQUEST3604
SEND_GROUP_JOIN_REQUEST_TO_INACTIVE_GROUP3605
SEND_GROUP_JOIN_REQUEST_TO_GROUP_USING_MEMBERSHIP_REQUEST3606
SEND_GROUP_JOIN_REQUEST_TO_GROUP_USING_INVITATION3607
SEND_GROUP_JOIN_REQUEST_TO_GROUP_USING_QUESTION3608
RECALLING_GROUP_JOIN_REQUEST_IS_DISABLED3609
UPDATE_NON_PENDING_GROUP_JOIN_REQUEST3610
NOT_GROUP_OWNER_OR_MANAGER_TO_UPDATE_GROUP_JOIN_REQUEST3611
群组 - 邀请相关错误SEND_GROUP_INVITATION_TO_GROUP_MEMBER3700
SEND_GROUP_INVITATION_TO_BLOCKED_USER3701
SEND_GROUP_INVITATION_TO_GROUP_NOT_REQUIRING_USERS_APPROVAL3702
NOT_GROUP_OWNER_TO_SEND_GROUP_INVITATION3703
NOT_GROUP_OWNER_OR_MANAGER_TO_SEND_GROUP_INVITATION3704
NOT_GROUP_MEMBER_TO_SEND_GROUP_INVITATION3705
RECALLING_GROUP_INVITATION_IS_DISABLED3706
NOT_GROUP_OWNER_OR_MANAGER_TO_RECALL_GROUP_INVITATION3707
NOT_GROUP_OWNER_OR_MANAGER_OR_SENDER_TO_RECALL_GROUP_INVITATION3708
RECALL_NON_PENDING_GROUP_INVITATION3709
UPDATE_NON_PENDING_GROUP_INVITATION3710
NOT_INVITEE_TO_UPDATE_GROUP_INVITATION3711
NOT_GROUP_OWNER_OR_MANAGER_TO_QUERY_GROUP_INVITATION3712
聊天会话 - 查阅时间相关错误UPDATING_READ_DATE_IS_DISABLED4000
UPDATING_READ_DATE_IS_DISABLED_BY_GROUP4001
UPDATING_READ_DATE_OF_NONEXISTENT_GROUP_CONVERSATION4002
NOT_GROUP_MEMBER_TO_UPDATE_READ_DATE_OF_GROUP_CONVERSATION4003
MOVING_READ_DATE_FORWARD_IS_DISABLED4004
聊天会话 - 输入状态相关错误UPDATING_TYPING_STATUS_IS_DISABLED4100
NOT_GROUP_MEMBER_TO_SEND_TYPING_STATUS4101
NOT_FRIEND_TO_SEND_TYPING_STATUS4102
消息 - 发送相关错误MESSAGE_RECIPIENT_NOT_ACTIVE5000
NOT_FRIEND_TO_SEND_PRIVATE_MESSAGE5001
BLOCKED_USER_SEND_PRIVATE_MESSAGE5002
BLOCKED_USER_SEND_GROUP_MESSAGE5003
SEND_MESSAGE_TO_INACTIVE_GROUP5004
SEND_MESSAGE_TO_MUTED_GROUP5005
SEND_MESSAGE_TO_NONEXISTENT_GROUP5006
SENDING_MESSAGES_TO_ONESELF_IS_DISABLED5007
MUTED_GROUP_MEMBER_SEND_MESSAGE5008
NOT_SPEAKABLE_GROUP_GUEST_TO_SEND_MESSAGE5009
MESSAGE_IS_ILLEGAL5010
NOT_MESSAGE_RECIPIENT_OR_SENDER_TO_FORWARD_MESSAGE5011
消息 - 更新相关错误UPDATING_MESSAGE_BY_SENDER_IS_DISABLED5100
NOT_SENDER_TO_UPDATE_MESSAGE5101
UPDATE_MESSAGE_OF_NONEXISTENT_GROUP5102
UPDATING_GROUP_MESSAGE_BY_SENDER_IS_DISABLED5103
消息 - 撤回相关错误RECALL_NONEXISTENT_MESSAGE5200
RECALLING_MESSAGE_IS_DISABLED5201
NOT_SENDER_TO_RECALL_MESSAGE5202
RECALL_MESSAGE_OF_NONEXISTENT_GROUP5203
MESSAGE_RECALL_TIMEOUT5204
消息 - 查询相关错误NOT_GROUP_MEMBER_TO_QUERY_GROUP_MESSAGES5300
存储 - 通用错误STORAGE_NOT_IMPLEMENTED6000
存储 - 消息附件相关错误NOT_FRIEND_TO_UPLOAD_MESSAGE_ATTACHMENT_IN_PRIVATE_CONVERSATION6100
NOT_GROUP_MEMBER_TO_UPLOAD_MESSAGE_ATTACHMENT_IN_GROUP_CONVERSATION6101
NOT_UPLOADER_TO_SHARE_MESSAGE_ATTACHMENT6102
NOT_UPLOADER_OR_GROUP_MANAGER_TO_UNSHARE_MESSAGE_ATTACHMENT_IN_GROUP_CONVERSATION6103
NOT_UPLOADER_TO_UNSHARE_MESSAGE_ATTACHMENT_IN_PRIVATE_CONVERSATION6104
NOT_UPLOADER_OR_GROUP_MANAGER_TO_DELETE_MESSAGE_ATTACHMENT_IN_GROUP_CONVERSATION6105
NOT_UPLOADER_TO_DELETE_MESSAGE_ATTACHMENT_IN_PRIVATE_CONVERSATION6106
NOT_UPLOADER_OR_SHARED_WITH_USER_TO_DOWNLOAD_MESSAGE_ATTACHMENT6107
存储 - 消息附件信息相关错误NOT_FRIEND_TO_QUERY_MESSAGE_ATTACHMENT_INFO_IN_PRIVATE_CONVERSATION6130
NOT_GROUP_MEMBER_TO_QUERY_MESSAGE_ATTACHMENT_INFO_IN_GROUP_CONVERSATION6131

SessionCloseStatus

SessionCloseStatus表明会话关闭的原因。

具体的状态码声明可查阅im.turms.server.common.access.common.SessionCloseStatus类。

原因类别名称状态码含义
客户端非法行为ILLEGAL_REQUEST100非法请求
HEARTBEAT_TIMEOUT110心跳超时
LOGIN_TIMEOUT111登录超时
SWITCH112会话超时,TCP或WebSocket切换为UDP进入休眠保活状态
服务端行为SERVER_ERROR200服务端异常错误
SERVER_CLOSED201服务端进入停机状态
SERVER_UNAVAILABLE202服务不可用
网络层错误CONNECTION_CLOSED300未收到关闭帧,网络层连接被强制关闭
未知错误UNKNOWN_ERROR400未知的服务端或客户端行为错误
用户主动关闭DISCONNECTED_BY_CLIENT500当前用户主动请求关闭会话
DISCONNECTED_BY_OTHER_DEVICE501由于当前用户的其他设备上线,导致当前会话关闭
管理员主动关闭DISCONNECTED_BY_ADMIN600管理员通过API主动关闭会话
用户状态变更USER_IS_DELETED_OR_INACTIVATED700用户账号被删除或进入未激活状态
USER_IS_BLOCKED701用户IP或用户ID被封禁