XTLS/Xray-core · error

failed to read request command

Error message

failed to read request command

What it means

DecodeRequestHeader could not read the single command byte following the addons section. The stream truncated after addons — the client disconnected mid-header or the stream is corrupt; no command (TCP/UDP/Mux/Rvs) can be determined.

Solutions

  1. Terminate the connection
  2. Verify the client completes its header writes
  3. Check for connections killed between header fields
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at proxy/vless/encoding/encoding.go:110 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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

Appendix: source

Thrown at proxy/vless/encoding/encoding.go:110

		}

		if request.User = validator.Get(id); request.User == nil {
			u := uuid.UUID(id)
			return nil, nil, nil, isfb, errors.New("invalid request user id: " + u.String())
		}

		if isfb {
			first.Advance(17)
		}

		requestAddons, err := DecodeHeaderAddons(&buffer, reader)
		if err != nil {
			return nil, nil, nil, false, errors.New("failed to decode request header addons").Base(err)
		}

		buffer.Clear()
		if _, err := buffer.ReadFullFrom(reader, 1); err != nil {
			return nil, nil, nil, false, errors.New("failed to read request command").Base(err)
		}

		request.Command = protocol.RequestCommand(buffer.Byte(0))
		switch request.Command {
		case protocol.RequestCommandMux:
			request.Address = net.DomainAddress("v1.mux.cool")
		case protocol.RequestCommandRvs:
			request.Address = net.DomainAddress("v1.rvs.cool")
		case protocol.RequestCommandTCP, protocol.RequestCommandUDP:
			if addr, port, err := addrParser.ReadAddressPort(&buffer, reader); err == nil {
				request.Address = addr
				request.Port = port
			}
		}
		if request.Address == nil {
			return nil, nil, nil, false, errors.New("invalid request address")
		}
		return id[:], request, requestAddons, false, nil

View on GitHub (pinned to 7d214f8b09)