{"record":{"id":"30435f74fbe9f4be","repo":"XTLS/Xray-core","slug":"write-login-start-w","errorCode":null,"errorMessage":"write login start: %w","messagePattern":"write login start: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"transport/internet/finalmask/xmc/client.go","lineNumber":117,"sourceCode":"\t\t}\n\t}\n\n\terr = writePacket(c.writer, 0x00, &protocolVersion, &serverAddress, &serverPort, &nextState)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"write handshake packet: %w\", err)\n\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","sourceCodeStart":99,"sourceCodeEnd":135,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/transport/internet/finalmask/xmc/client.go#L99-L135","documentation":"Wraps a writePacket failure when sending the Minecraft Login Start packet (packet ID 0x00 carrying the selected profile's username and UUID) right after the protocol handshake. Like error 853, the %w chains the underlying conn write error; this is the second packet on the wire, so failures here mean the connection degraded between the two writes.","triggerScenarios":"Server closing the connection after receiving the handshake packet (wrong next-state, protocol version mismatch), write deadline expiry, or a reset from a middlebox. The username/UUID fields are small, so partial-write issues are rare.","commonSituations":"Protocol version 775 not accepted by the target server; connecting to a Minecraft server in a state that rejects logins (whitelist, full server); network path resetting mid-handshake.","solutions":["Confirm the target is a Minecraft login server accepting protocol 775 clients.","Unwrap the error to distinguish timeout vs. ECONNRESET.","Retry with a fresh connection once transient network issues are ruled out."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := cc.Handshake(); err != nil {\n\tif isWriteErr(err) { // timeout, reset, broken pipe\n\t\treturn retryDial(ctx) // new conn, restart from handshake packet\n\t}\n\treturn err\n}","preventionTips":["Confirm the server accepts protocol version 775 logins; some rejections surface as an immediate close after Login Start.","Size handshake deadlines generously for high-latency paths."],"tags":["network","xmc","finalmask","handshake","write"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}