fish2018/pansou · error

[ ] 计算访问挑战失败

Error message

[%s] 计算访问挑战失败

What it means

After fetching the challenge, ensureSession calls solveChallenge to compute a proof-of-work nonce; this error means solveChallenge returned an empty string, i.e. no valid nonce was found for the given challenge and difficulty. The PoW was not solved, so the session cannot be issued and the search fails.

Solutions

  1. Inspect solveChallenge's iteration cap and raise it, or make it difficulty-aware, when difficultyBits increases
  2. Log challenge and difficultyBits alongside the failure to reproduce the PoW failure
  3. Verify the hash algorithm/prefix expected by the site hasn't changed and update solveChallenge
  4. Retry the whole ensureSession — a fresh challenge may be easier or valid for the solver
  5. Run the solver on more parallel goroutines if difficulty is legitimately high

Example fix

// before
nonce := solveChallenge(challenge.Data.Challenge, challenge.Data.DifficultyBits)
if nonce == "" {
    return fmt.Errorf("[%s] 计算访问挑战失败", p.Name())
}
// after
nonce := solveChallenge(challenge.Data.Challenge, challenge.Data.DifficultyBits)
if nonce == "" {
    return fmt.Errorf("[%s] 计算访问挑战失败: difficulty=%d, challenge=%s", p.Name(), challenge.Data.DifficultyBits, challenge.Data.Challenge)
}
Defensive patterns

Strategy: retry

Try / catch

results, err := plugin.Search(keyword, ext)
if err != nil && strings.Contains(err.Error(), "计算访问挑战失败") {
    // fresh challenge may be easier: re-run once
    results, err = plugin.Search(keyword, ext)
}

Prevention

When it happens

Trigger: solveChallenge exhausts its nonce search space / iteration limit without finding a hash meeting difficultyBits, or it returns "" due to an unexpected challenge format (e.g. non-hex challenge string) it cannot hash.

Common situations: The site raised difficultyBits so the solver's max-iterations cap is too low; the challenge format changed (longer salt, different hash algorithm) breaking the solver; CPU-constrained host times out before solving.

Understand the failure class

Background: "invalid response format", "malformed payload", "missing data field": when an API returns 200 but the response shape is wrong — this error's family across 23 libraries.

Related errors


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

Appendix: source

Thrown at plugin/nsgame/nsgame.go:326

func (p *NSGameAsyncPlugin) ensureSession(client *http.Client) error {
	status, err := p.postSession(client, "/traffic/session/status", nil)
	if err != nil {
		return err
	}
	if status {
		return nil
	}
	challengeBody, err := p.postSessionRaw(client, "/traffic/session/challenge", nil)
	if err != nil {
		return err
	}
	var challenge nsgameChallengeResponse
	if err := json.Unmarshal(challengeBody, &challenge); err != nil || !challenge.Success || challenge.Data.Challenge == "" {
		return fmt.Errorf("[%s] 获取访问挑战失败", p.Name())
	}
	nonce := solveChallenge(challenge.Data.Challenge, challenge.Data.DifficultyBits)
	if nonce == "" {
		return fmt.Errorf("[%s] 计算访问挑战失败", p.Name())
	}
	issueBody, _ := json.Marshal(map[string]string{"challenge": challenge.Data.Challenge, "nonce": nonce})
	if _, err := p.postSessionRaw(client, "/traffic/session/issue", issueBody); err != nil {
		return err
	}
	return nil
}

func (p *NSGameAsyncPlugin) postSession(client *http.Client, path string, body []byte) (bool, error) {
	data, err := p.postSessionRaw(client, path, body)
	if err != nil {
		return false, err
	}
	var response nsgameSessionResponse
	if err := json.Unmarshal(data, &response); err != nil {
		return false, fmt.Errorf("[%s] 解析会话响应失败: %w", p.Name(), err)
	}
	active, _ := response.Data.(bool)

View on GitHub (pinned to beaa561337)