XTLS/Xray-core · error

invalid negative value of maxHeaderBytes

Error message

invalid negative value of maxHeaderBytes

What it means

SplitHTTPConfig.Build() rejects negative "serverMaxHeaderBytes" at transport_method.go:445-447. This field (int32, mapped from json "serverMaxHeaderBytes") bounds the size of headers the server will read; negative values are meaningless. Zero is allowed and typically means 'use Go http.Server default' semantics.

Source

Thrown at infra/conf/transport_method.go:446

		switch c.SeqPlacement {
		case "cookie", "query":
			c.SeqKey = "x_seq"
		case "header":
			c.SeqKey = "X-Seq"
		}
	}

	if c.UplinkDataPlacement != splithttp.PlacementBody && c.UplinkDataKey == "" {
		switch c.UplinkDataPlacement {
		case splithttp.PlacementCookie:
			c.UplinkDataKey = "x_data"
		case splithttp.PlacementAuto, splithttp.PlacementHeader:
			c.UplinkDataKey = "X-Data"
		}
	}

	if c.ServerMaxHeaderBytes < 0 {
		return nil, errors.New("invalid negative value of maxHeaderBytes")
	}

	if c.Xmux.MaxConnections.To > 0 && c.Xmux.MaxConcurrency.To > 0 {
		return nil, errors.New("maxConnections cannot be specified together with maxConcurrency")
	}
	if c.Xmux == (XmuxConfig{}) {
		c.Xmux.MaxConnections.From = 3
		c.Xmux.MaxConnections.To = 3
		c.Xmux.HMaxRequestTimes.From = 600
		c.Xmux.HMaxRequestTimes.To = 900
		c.Xmux.HMaxReusableSecs.From = 1800
		c.Xmux.HMaxReusableSecs.To = 3000
	}

	config := &splithttp.Config{
		Host:                 c.Host,
		Path:                 c.Path,
		Mode:                 c.Mode,

View on GitHub (pinned to 7d214f8b09)

Solutions

  1. Remove "serverMaxHeaderBytes" to use the default
  2. Or set it to a non-negative byte count: "serverMaxHeaderBytes": 8192

Example fix

// before
"serverMaxHeaderBytes": -1
// after
"serverMaxHeaderBytes": 8192
Defensive patterns

Strategy: validation

Validate before calling

// Go: non-negative serverMaxHeaderBytes
if cfg.ServerMaxHeaderBytes < 0 {
	return errors.New("serverMaxHeaderBytes must be >= 0 or omitted")
}

Prevention

When it happens

Trigger: "serverMaxHeaderBytes": -1 (or any negative) in splithttp transportSettings on the inbound/server side; a negative value inside "extra" copied into the effective config.

Common situations: Copy-paste arithmetic errors; intending 'unlimited' and writing -1 (not supported — use a large positive value or omit); sign typos.

Related errors


AI-assisted analysis of XTLS/Xray-core@7d214f8b09 (2026-08-15). Data as JSON: /api/errors/6d77fe847531dc14. Report an issue: GitHub.