XX-net/XX-Net · warning

response length incorrect, head len:%s, content len:%d retry

Error message

response length incorrect, head len:%s, content len:%d retry it

What it means

The response Content-Length header disagrees with the actual bytes read, so the payload is considered truncated/corrupt and the dispatcher retries. Indicates the front connection was cut mid-body or a proxy tampered with the body.

Source

Thrown at code/default/x_tunnel/local/front_dispatcher.py:196

            if g.server_host:
                host = g.server_host

        headers["X-Async"] = "1"
        if len(data) < 84:
            padding = utils.to_str(utils.generate_random_lowercase(random.randint(8, 64)))
            headers["Padding"] = padding

        content, status, response = front.request(
            method, host=host, path=path, headers=dict(headers), data=data, timeout=timeout)

        if status not in [200, 521, 400, 404]:
            xlog.warn("front retry %s%s", host, path)
            time.sleep(1)
            continue

        header_len = int(response.headers.get(b"Content-Length", 0))
        if header_len and len(content) != header_len:
            xlog.warn("response length incorrect, head len:%s, content len:%d retry it", header_len, len(content))
            time.sleep(1)
            continue

        return content, status, response

    return content, status, response


def set_session_host(host):
    global session_fronts
    for front in session_fronts:
        dispatcher = front.get_dispatcher(host)
        if not dispatcher:
            continue

        dispatcher.set_session_host(host)

View on GitHub (pinned to cfa5bc17b6)

Solutions

  1. Retry (dispatcher already sleeps 1s and retries — usually transient)
  2. Check network stability / try different fronts
  3. If persistent for one front, mark that front domain as bad and update the list
Defensive patterns

Strategy: retry

Prevention

When it happens

Trigger: front.request returns content shorter/longer than Content-Length: connection reset mid-transfer, worker buffering bug, or middlebox modifying responses.

Common situations: Unstable networks, GFW RST injection on TLS flows, or a front worker with broken chunked handling.

Related errors


AI-assisted analysis of XX-net/XX-Net@cfa5bc17b6 (2026-08-27). Data as JSON: /api/errors/faa3aa2691a94289. Report an issue: GitHub.