{"record":{"id":"2917d5215cf7d875","repo":"XTLS/Xray-core","slug":"failed-to-read-first-request","errorCode":null,"errorMessage":"failed to read first request","messagePattern":"failed to read first request","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/trojan/server.go","lineNumber":161,"sourceCode":"// Network implements proxy.Inbound.Network().\nfunc (s *Server) Network() []net.Network {\n\treturn []net.Network{net.Network_TCP, net.Network_UNIX}\n}\n\n// Process implements proxy.Inbound.Process().\nfunc (s *Server) Process(ctx context.Context, network net.Network, conn stat.Connection, dispatcher routing.Dispatcher) error {\n\tiConn := stat.TryUnwrapStatsConn(conn)\n\n\tsessionPolicy := s.policyManager.ForLevel(0)\n\tif err := conn.SetReadDeadline(time.Now().Add(sessionPolicy.Timeouts.Handshake)); err != nil {\n\t\treturn errors.New(\"unable to set read deadline\").Base(err).AtWarning()\n\t}\n\n\tfirst := buf.FromBytes(make([]byte, buf.Size))\n\tfirst.Clear()\n\tfirstLen, err := first.ReadFrom(conn)\n\tif err != nil {\n\t\treturn errors.New(\"failed to read first request\").Base(err)\n\t}\n\terrors.LogInfo(ctx, \"firstLen = \", firstLen)\n\n\tbufferedReader := &buf.BufferedReader{\n\t\tReader: buf.NewReader(conn),\n\t\tBuffer: buf.MultiBuffer{first},\n\t}\n\n\tvar user *protocol.MemoryUser\n\n\tnapfb := s.fallbacks\n\tisfb := napfb != nil\n\n\tshouldFallback := false\n\tif firstLen < 58 || first.Byte(56) != '\\r' {\n\t\t// invalid protocol\n\t\terr = errors.New(\"not trojan protocol\")\n\t\tlog.Record(&log.AccessMessage{","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/trojan/server.go#L143-L179","documentation":"Error \"failed to read first request\" thrown in XTLS/Xray-core.","triggerScenarios":"Thrown at proxy/trojan/server.go:161 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}