fish2018/pansou · error

获取 Anubis 验证题目失败

Error message

获取 Anubis 验证题目失败: %w

What it means

completeAnubisChallenge sends a GET to the Anubis-protected site root to fetch a proof-of-work challenge page. This error wraps the http.Client.Do failure for that initial request (miosou.go:162). ensureGate retries up to 3 times before surfacing it as 人机验证未通过.

Solutions

  1. Check basic connectivity to the site (curl -v the baseURL) and DNS/proxy settings.
  2. Verify the HTTP client's proxy/timeout configuration (http.Transport, http.ProxyFromEnvironment).
  3. Rely on ensureGate's 3 retries; increase gateTimeout if the network is slow.
  4. If Anubis blocks the client, verify setPageHeaders sends a browser-like User-Agent.

Example fix

// before
resp, err := p.client.Do(req)
if err != nil {
    return fmt.Errorf("获取 Anubis 验证题目失败: %w", err)
}
// after
resp, err := p.client.Do(req)
if err != nil {
    if errors.Is(err, context.DeadlineExceeded) {
        return fmt.Errorf("获取 Anubis 验证题目超时: %w", err)
    }
    return fmt.Errorf("获取 Anubis 验证题目失败: %w", err)
}
Defensive patterns

Strategy: retry

Validate before calling

// check reachability before calling
resp, err := http.Head(baseURL + "/")
if err != nil {
    return fmt.Errorf("site unreachable: %w", err)
}
resp.Body.Close()

Try / catch

err := p.ensureGate()
if err != nil {
    var netErr net.Error
    if errors.As(err, &netErr) && netErr.Timeout() {
        // back off and retry later
    }
    return err
}

Prevention

When it happens

Trigger: p.client.Do on GET baseURL+/ fails: DNS failure, connection refused/reset, TLS error, request context (gateTimeout) expired, or proxy unreachable.

Common situations: No internet/VPN, corporate proxy or firewall blocking the host, the miosou site being down or Anubis blocking non-browser clients, or gateTimeout being too short on slow networks.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


AI-assisted analysis of fish2018/pansou@beaa561337 (2026-09-07). Data as JSON: /api/errors/f6a08b98506a42a8. Report an issue: GitHub.

Appendix: source

Thrown at plugin/miosou/miosou.go:162

		cancel()
		if err == nil {
			p.gateReady = true
			return nil
		}
		lastErr = err
	}
	return fmt.Errorf("[%s] 人机验证未通过: %w", p.Name(), lastErr)
}

func (p *MiosouPlugin) completeAnubisChallenge(ctx context.Context) error {
	req, err := http.NewRequestWithContext(ctx, http.MethodGet, baseURL+"/", nil)
	if err != nil {
		return fmt.Errorf("创建 Anubis 验证请求失败: %w", err)
	}
	setPageHeaders(req)
	resp, err := p.client.Do(req)
	if err != nil {
		return fmt.Errorf("获取 Anubis 验证题目失败: %w", err)
	}
	body, readErr := io.ReadAll(io.LimitReader(resp.Body, 1<<20))
	resp.Body.Close()
	if readErr != nil {
		return fmt.Errorf("读取 Anubis 验证题目失败: %w", readErr)
	}
	challenge, found, err := parseAnubisChallenge(body)
	if err != nil {
		return err
	}
	if !found {
		if resp.StatusCode == http.StatusOK && !isAnubisGateResponse(resp) {
			return nil
		}
		return fmt.Errorf("Anubis 验证页返回状态码 %d", resp.StatusCode)
	}

	startedAt := time.Now()

View on GitHub (pinned to beaa561337)