{"record":{"id":"ed932c47cbd6c350","repo":"XTLS/Xray-core","slug":"failed-to-deliver-response-payload","errorCode":null,"errorMessage":"failed to deliver response payload","messagePattern":"failed to deliver response payload","errorType":"console","errorClass":null,"httpStatus":null,"severity":"info","filePath":"proxy/trojan/server.go","lineNumber":537,"sourceCode":"\t\t\t\tp2, _ := strconv.ParseUint(localPort, 10, 16)\n\t\t\t\tcommon.Must2(pro.Write([]byte{byte(p1 >> 8), byte(p1), byte(p2 >> 8), byte(p2)}))\n\t\t\t}\n\t\t\tif err := serverWriter.WriteMultiBuffer(buf.MultiBuffer{pro}); err != nil {\n\t\t\t\treturn errors.New(\"failed to set PROXY protocol v\", fb.Xver).Base(err).AtWarning()\n\t\t\t}\n\t\t}\n\t\tif err := buf.Copy(reader, serverWriter, buf.UpdateActivity(timer)); err != nil {\n\t\t\treturn errors.New(\"failed to fallback request payload\").Base(err).AtInfo()\n\t\t}\n\t\treturn nil\n\t}\n\n\twriter := buf.NewWriter(connection)\n\n\tgetResponse := func() error {\n\t\tdefer timer.SetTimeout(sessionPolicy.Timeouts.UplinkOnly)\n\t\tif err := buf.Copy(serverReader, writer, buf.UpdateActivity(timer)); err != nil {\n\t\t\treturn errors.New(\"failed to deliver response payload\").Base(err).AtInfo()\n\t\t}\n\t\treturn nil\n\t}\n\n\tif err := task.Run(ctx, task.OnSuccess(postRequest, task.Close(serverWriter)), task.OnSuccess(getResponse, task.Close(writer))); err != nil {\n\t\tcommon.Must(common.Interrupt(serverReader))\n\t\tcommon.Must(common.Interrupt(serverWriter))\n\t\treturn errors.New(\"fallback ends\").Base(err).AtInfo()\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":519,"sourceCodeEnd":550,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/trojan/server.go#L519-L550","documentation":"Raised in the trojan fallback path's response pump when buf.Copy from the fallback upstream to the connection writer failed; the chained error means delivering the fallback response to the client ended abnormally.","triggerScenarios":"Client TLS connection resets while the backend is still responding, or the context is cancelled by the inactivity timer during the UplinkOnly window.","commonSituations":"Prober timeouts, client closing on large error pages, mobile network churn.","solutions":["No action needed if fallback responses are being served in general","If responses never reach clients, verify TLS certificates on the fallback path match the SNI clients send","Correlate with the Base error to confirm it is a client-side write failure"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err := buf.Copy(serverReader, writer, buf.UpdateActivity(timer)); err != nil {\n    // client vanished while the backend responded; end fallback quietly\n    return errors.New(\"failed to deliver response payload\").Base(err).AtInfo()\n}","preventionTips":["Treat as expected behavior for prober clients with short timeouts","Ensure fallback TLS certificates match served SNI so clients do not abort mid-response","No remediation beyond the backend health practices in [730]/[731]"],"tags":["trojan","fallback","relay"],"backgroundTag":null,"analyzedSha":"7d214f8b094f75322fa3990f8aadad1c912f24f5","analyzedAt":"2026-08-15T14:26:24.325Z","contentChangedAt":"2026-08-15T14:26:24.325Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}