{"record":{"id":"62eaa84528e30c2e","repo":"XTLS/Xray-core","slug":"failed-to-process-response","errorCode":null,"errorMessage":"failed to process response","messagePattern":"failed to process response","errorType":"exception","errorClass":"errors.Error","httpStatus":null,"severity":"error","filePath":"proxy/freedom/freedom.go","lineNumber":449,"sourceCode":"\tresponseDone := func() error {\n\t\tdefer timer.SetTimeout(plcy.Timeouts.UplinkOnly)\n\t\tif destination.Network == net.Network_TCP && useSplice.Load() && proxy.IsRAWTransportWithoutSecurity(conn) { // it would be tls conn in special use case of MITM, we need to let link handle traffic\n\t\t\tvar writeConn net.Conn\n\t\t\tvar inTimer *signal.ActivityTimer\n\t\t\tif inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Conn != nil {\n\t\t\t\twriteConn = inbound.Conn\n\t\t\t\tinTimer = inbound.Timer\n\t\t\t}\n\t\t\treturn proxy.CopyRawConnIfExist(ctx, conn, writeConn, link.Writer, timer, inTimer)\n\t\t}\n\t\tvar reader buf.Reader\n\t\tif destination.Network == net.Network_TCP {\n\t\t\treader = buf.NewReader(conn)\n\t\t} else {\n\t\t\treader = NewPacketReader(conn, h, defaultRule, UDPOverride, destination)\n\t\t}\n\t\tif err := buf.Copy(reader, output, buf.UpdateActivity(timer)); err != nil {\n\t\t\treturn errors.New(\"failed to process response\").Base(err)\n\t\t}\n\t\treturn nil\n\t}\n\n\tif newCtx != nil {\n\t\tctx = newCtx\n\t}\n\n\tif err := task.Run(ctx, requestDone, task.OnSuccess(responseDone, task.Close(output))); err != nil {\n\t\treturn errors.New(\"connection ends\").Base(err)\n\t}\n\n\treturn nil\n}\n\nfunc NewPacketReader(conn net.Conn, h *Handler, defaultRule *FinalRule, UDPOverride net.Destination, DialDest net.Destination) buf.Reader {\n\tiConn := conn\n\tstatConn, ok := iConn.(*stat.CounterConnection)","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/freedom/freedom.go#L431-L467","documentation":"The downlink copy (remote → client) failed during buf.Copy(reader, output). The reader is a stream reader for TCP or NewPacketReader for UDP; any read error from the remote conn, write error to the inbound writer, or activity-timer expiry surfaces here, wrapped as \"failed to process response\".","triggerScenarios":"Remote server closes or RESETs mid-response, write to the client link fails (client went away), UDP session timeout in NewPacketReader, or downlinkOnly policy timeout firing while waiting for server data.","commonSituations":"Server-side idle timeouts (e.g. nginx keepalive) closing the flow, mobile clients backgrounding the app and dropping the socket, small downlinkOnly timeout on slow APIs, UDP NAT expiry mid-session.","solutions":["Inspect the Base error for io.EOF/ErrTimeout/reset signatures","Raise policy.Timeouts.downlinkOnly if servers legitimately pause between responses","For UDP, ensure session limits (policy.levels handshake/connIdle) fit the application's inter-packet gaps","Check for path MTU issues if transfers stall deterministically at the same size"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"```go\nif err := h.Process(ctx, link, dialer); err != nil {\n    if errors.Is(err, io.EOF) { return }\n    if errors.Is(err, os.ErrDeadlineExceeded) { /* raise downlinkOnly */ }\n}\n```","preventionTips":["Raise downlinkOnly for servers that pause","Keep UDP sessions within NAT/policy lifetimes","Correlate with remote-side logs to identify who closed first"],"tags":["freedom","downlink","copy","timeout","xray"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}