{"record":{"id":"e14fc1eff33f6cc1","repo":"openimsdk/open-im-server","slug":"reqidentifier-failed-sendid-s-msgincr-s-reqident","errorCode":null,"errorMessage":"ReqIdentifier failed,sendID:%s,msgIncr:%s,reqIdentifier:%d","messagePattern":"ReqIdentifier failed,sendID:(.+?),msgIncr:(.+?),reqIdentifier:(.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/msggateway/client.go","lineNumber":205,"sourceCode":"\t\tresp, messageErr = c.longConnServer.SendMessage(ctx, binaryReq)\n\tcase WSSendSignalMsg:\n\t\tresp, messageErr = c.longConnServer.SendSignalMessage(ctx, binaryReq)\n\tcase WSPullMsgBySeqList:\n\t\tresp, messageErr = c.longConnServer.PullMessageBySeqList(ctx, binaryReq)\n\tcase WSPullMsg:\n\t\tresp, messageErr = c.longConnServer.GetSeqMessage(ctx, binaryReq)\n\tcase WSGetConvMaxReadSeq:\n\t\tresp, messageErr = c.longConnServer.GetConversationsHasReadAndMaxSeq(ctx, binaryReq)\n\tcase WsPullConvLastMessage:\n\t\tresp, messageErr = c.longConnServer.GetLastMessage(ctx, binaryReq)\n\tcase WsLogoutMsg:\n\t\tresp, messageErr = c.longConnServer.UserLogout(ctx, binaryReq)\n\tcase WsSetBackgroundStatus:\n\t\tresp, messageErr = c.setAppBackgroundStatus(ctx, binaryReq)\n\tcase WsSubUserOnlineStatus:\n\t\tresp, messageErr = c.longConnServer.SubUserOnlineStatus(ctx, c, binaryReq)\n\tdefault:\n\t\treturn fmt.Errorf(\n\t\t\t\"ReqIdentifier failed,sendID:%s,msgIncr:%s,reqIdentifier:%d\",\n\t\t\tbinaryReq.SendID,\n\t\t\tbinaryReq.MsgIncr,\n\t\t\tbinaryReq.ReqIdentifier,\n\t\t)\n\t}\n\n\treturn c.replyMessage(ctx, binaryReq, messageErr, resp)\n}\n\nfunc (c *Client) setAppBackgroundStatus(ctx context.Context, req *Req) ([]byte, error) {\n\tresp, isBackground, messageErr := c.longConnServer.SetUserDeviceBackground(ctx, req)\n\tif messageErr != nil {\n\t\treturn nil, messageErr\n\t}\n\n\tc.IsBackground = isBackground\n\t// TODO: callback","sourceCodeStart":187,"sourceCodeEnd":223,"githubUrl":"https://github.com/openimsdk/open-im-server/blob/175a7bb0673eca18e9d1b10bff4f728da6b1b513/internal/msggateway/client.go#L187-L223","documentation":"The WebSocket gateway's handleMessage dispatches on the request's ReqIdentifier. If the identifier matches none of the known message types (WsLogin, WsLogout, WsSendMessage, etc.), the default branch returns this error carrying sendID, msgIncr and the raw identifier so the sender can correlate the failure. The client sent a protocol operation the server does not implement (or a corrupt/garbage identifier).","triggerScenarios":"A client sends a WS binary frame whose ReqIdentifier value is not one of the gateway's supported constants (wrong SDK version, hand-rolled client, corrupted frame, or endian/serialization mismatch).","commonSituations":"Custom/older SDK talking to a newer gateway; a client sending text instead of the expected binary protocol; protocol constants changed between server versions; fuzzer or security scanner hitting the WS endpoint.","solutions":["Upgrade the client SDK to a version matching the server's protocol constants","Log the failing ReqIdentifier value and check it against the gateway's Ws* constants in the protocol package","Fix the client's message encoding (ensure binary frames with correct field order/endian)","If intentionally adding a new op, implement its case in handleMessage"],"exampleFix":"// before\nconn.WriteJSON(map[string]interface{}{\"reqIdentifier\": 999}) // unsupported on server\n// after\nreq := sdkwsReq{ReqIdentifier: wsProtocol.WsSendMessage, ...}\nconn.WriteMessage(websocket.BinaryMessage, protoMarshal(req))","handlingStrategy":"type-guard","validationCode":"known := map[int32]bool{wsProtocol.WsLogin: true, wsProtocol.WsLogout: true, wsProtocol.WsSendMessage: true, wsProtocol.WsSubUserOnlineStatus: true}\nif !known[int32(req.ReqIdentifier)] {\n\t// reject before sending\n}","typeGuard":"func isKnownReqIdentifier(id int32) bool {\n\tswitch id {\n\tcase WsLogin, WsLogout, WsSendMessage, WsKickOnline, WsSubUserOnlineStatus, WsSetBackgroundStatus:\n\t\treturn true\n\t}\n\treturn false\n}","tryCatchPattern":"if err := c.handleMessage(ctx, binaryReq); err != nil {\n\tif strings.Contains(err.Error(), \"ReqIdentifier failed\") {\n\t\tlog.ZWarn(ctx, \"unsupported req identifier, check client/server protocol version\", err, \"reqIdentifier\", binaryReq.ReqIdentifier)\n\t\tc.sendErrMsg(binaryReq, err)\n\t\treturn\n\t}\n}","preventionTips":["Keep client SDK and server protocol constants on the same version","Validate ReqIdentifier client-side against the supported set before sending","Always send binary frames with the agreed encoding"],"tags":["websocket","protocol","client-server"],"backgroundTag":"unknown-message-type","analyzedSha":"175a7bb0673eca18e9d1b10bff4f728da6b1b513","analyzedAt":"2026-09-04T16:52:56.821Z","contentChangedAt":"2026-09-04T16:52:56.821Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}