XTLS/Xray-core · error
failed to decode response header addons
Error message
failed to decode response header addons
What it means
DecodeResponseHeader called DecodeHeaderAddons to parse the server's response addons and it failed (length read, payload read, or unmarshal). The response stream is truncated or malformed; the session cannot proceed.
Solutions
- Fail the outbound connection and optionally retry
- Verify version compatibility and transport integrity
- Inspect the chained addon error for the specific stage
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at proxy/vless/encoding/encoding.go:169 when the library encounters an invalid state.
Common situations: See trigger scenarios.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15).
Data as JSON: /api/errors/5081fdf62d72e811.
Report an issue: GitHub.
Appendix: source
Thrown at proxy/vless/encoding/encoding.go:169
return nil
}
// DecodeResponseHeader decodes and returns (if successful) a ResponseHeader from an input stream.
func DecodeResponseHeader(reader io.Reader, request *protocol.RequestHeader) (*Addons, error) {
buffer := buf.StackNew()
defer buffer.Release()
if _, err := buffer.ReadFullFrom(reader, 1); err != nil {
return nil, errors.New("failed to read response version").Base(err)
}
if buffer.Byte(0) != request.Version {
return nil, errors.New("unexpected response version. Expecting ", int(request.Version), " but actually ", int(buffer.Byte(0)))
}
responseAddons, err := DecodeHeaderAddons(&buffer, reader)
if err != nil {
return nil, errors.New("failed to decode response header addons").Base(err)
}
return responseAddons, nil
}
// XtlsRead can switch to splice copy
func XtlsRead(reader buf.Reader, writer buf.Writer, timer *signal.ActivityTimer, conn net.Conn, trafficState *proxy.TrafficState, isUplink bool, ctx context.Context) error {
err := func() error {
for {
if isUplink && trafficState.Inbound.UplinkReaderDirectCopy || !isUplink && trafficState.Outbound.DownlinkReaderDirectCopy {
var writerConn net.Conn
var inTimer *signal.ActivityTimer
if inbound := session.InboundFromContext(ctx); inbound != nil && inbound.Conn != nil {
writerConn = inbound.Conn
inTimer = inbound.Timer
}
return proxy.CopyRawConnIfExist(ctx, conn, writerConn, writer, timer, inTimer)
}View on GitHub (pinned to 7d214f8b09)