{"record":{"id":"00975e811eb907ac","repo":"XTLS/Xray-core","slug":"failed-to-write-request-header","errorCode":null,"errorMessage":"failed to write request header","messagePattern":"failed to write request header","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"proxy/trojan/protocol.go","lineNumber":42,"sourceCode":"\tmaxLength = 8192\n\n\tcommandTCP byte = 1\n\tcommandUDP byte = 3\n)\n\n// ConnWriter is TCP Connection Writer Wrapper for trojan protocol\ntype ConnWriter struct {\n\tio.Writer\n\tTarget     net.Destination\n\tAccount    *MemoryAccount\n\theaderSent bool\n}\n\n// Write implements io.Writer\nfunc (c *ConnWriter) Write(p []byte) (n int, err error) {\n\tif !c.headerSent {\n\t\tif err := c.writeHeader(); err != nil {\n\t\t\treturn 0, errors.New(\"failed to write request header\").Base(err)\n\t\t}\n\t}\n\n\treturn c.Writer.Write(p)\n}\n\n// WriteMultiBuffer implements buf.Writer\nfunc (c *ConnWriter) WriteMultiBuffer(mb buf.MultiBuffer) error {\n\tdefer buf.ReleaseMulti(mb)\n\n\tfor _, b := range mb {\n\t\tif !b.IsEmpty() {\n\t\t\tif _, err := c.Write(b.Bytes()); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/XTLS/Xray-core/blob/7d214f8b094f75322fa3990f8aadad1c912f24f5/proxy/trojan/protocol.go#L24-L60","documentation":"Error \"failed to write request header\" thrown in XTLS/Xray-core.","triggerScenarios":"Thrown at proxy/trojan/protocol.go:42 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-15T17:31:12.345Z"}