{"record":{"id":"ed155caa13b50a84","repo":"XTLS/Xray-core","slug":"read-encryption-request-w","errorCode":null,"errorMessage":"read encryption request: %w","messagePattern":"read encryption request: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"transport/internet/finalmask/xmc/client.go","lineNumber":123,"sourceCode":"\t}\n\n\t// Login Start\n\trandomProfile, err := rand.Int(rand.Reader, big.NewInt(int64(len(c.profiles))))\n\tif err != nil {\n\t\treturn fmt.Errorf(\"select profile: %w\", err)\n\t}\n\tselectedProfile := c.profiles[randomProfile.Int64()]\n\tusername := String(selectedProfile.Username)\n\n\terr = writePacket(c.writer, 0x00, &username, &selectedProfile.UUID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"write login start: %w\", err)\n\t}\n\n\t// Encryption Request\n\tpkt, err := readPacket(c.reader)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"read encryption request: %w\", err)\n\t}\n\n\tif pkt.packetID != 0x01 {\n\t\treturn fmt.Errorf(\"bad encrypt request packet id\")\n\t}\n\n\tvar (\n\t\tserverId    String\n\t\tpublicKey   Bytes\n\t\tverifyToken Bytes\n\t)\n\n\terr = pkt.readFields(&serverId, &publicKey, &verifyToken)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"read encryption request fields: %w\", err)\n\t}\n\n\tif !bytes.Equal(publicKey, c.rsaPublicKey) {","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/transport/internet/finalmask/xmc/client.go#L105-L141","documentation":"Wraps a readPacket failure while waiting for the server's Encryption Request during the login handshake. The %w chains the underlying reader error: EOF (server closed without responding), i/o timeout (handshake deadline expired), or a framing error if the peer's bytes are not Minecraft varint-framed packets.","triggerScenarios":"The server accepting TCP but never sending an Encryption Request: wrong service on the port, a vanilla server with online-mode off that skips encryption, or a non-Minecraft target. Also triggered when the read deadline from beginHandshake elapses first.","commonSituations":"Pointing the transport at a plain HTTP/TLS/proxy port instead of the Minecraft port; server requiring a different login flow; slow servers that exceed the handshake deadline.","solutions":["Verify the port serves the Minecraft login protocol and that encryption (online-mode style) is expected.","Unwrap to check for EOF vs. timeout: EOF means the server hung up, timeout means it stayed silent.","Test the same host/port with a real Minecraft client to confirm the server behaves as expected."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := cc.Handshake(); err != nil {\n\tvar opErr *net.OpError\n\tif errors.As(err, &opErr) && errors.Is(opErr.Err, os.ErrDeadlineExceeded) {\n\t\treturn fmt.Errorf(\"server silent after Login Start (wrong port or no encryption?): %w\", err)\n\t}\n\tif errors.Is(err, io.EOF) || errors.Is(err, io.ErrUnexpectedEOF) {\n\t\treturn fmt.Errorf(\"server closed during login: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Pre-check the endpoint with a Minecraft Server List Ping before configuring the transport.","EOF vs. timeout distinguishes 'server refused' from 'server slow'; log the unwrapped cause."],"tags":["network","xmc","finalmask","handshake","read"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}