fish2018/pansou · error

[ ] 搜索请求失败

Error message

[%s] 搜索请求失败: %w

What it means

The HTTP GET issued by dyyj.executeSearchHTML failed after doRequestWithRetry exhausted its attempts. This wraps transport-level failures: DNS resolution failure, TCP connect refused/reset, TLS handshake errors, or context deadline exceeded. Retries have already happened inside doRequestWithRetry.

Solutions

  1. Check connectivity: curl -v the same searchURL from the host
  2. Inspect the wrapped error (timeout vs connection refused vs TLS) to pick the fix
  3. Increase RequestTimeout if timeouts are the cause
  4. Configure HTTP(S)_PROXY if the host needs a proxy to reach the site
  5. Verify DNS (dig/nslookup) — the domain may have changed

Example fix

// before
client := &http.Client{}
// after
client := &http.Client{
	Timeout: 30 * time.Second,
	Transport: &http.Transport{
		Proxy: http.ProxyFromEnvironment,
		TLSHandshakeTimeout: 10 * time.Second,
	},
}
Defensive patterns

Strategy: retry

Validate before calling

if !isReachable(BaseURL) { return errors.New("site unreachable, skipping search") }
// isReachable: quick TCP dial or HEAD with short timeout before batch search runs

Try / catch

var netErr net.Error
if errors.As(err, &netErr) && netErr.Timeout() {
	return nil, fmt.Errorf("search timed out after retries: %w", err)
}
return nil, fmt.Errorf("search transport failed: %w", err)

Prevention

When it happens

Trigger: p.doRequestWithRetry(req, client) returned a non-nil error — DNS failure for the site domain, connection refused, TLS certificate problems, timeout from the ctx created with RequestTimeout, or proxy misconfiguration.

Common situations: The site is down or blocks the host's IP/region; corporate proxy needed but not configured; DNS cannot resolve a changed domain; RequestTimeout too small for a slow site; GFW/network filtering in the deployment environment.

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/12d4dc5947c3e9bc. Report an issue: GitHub.

Appendix: source

Thrown at plugin/dyyj/dyyj.go:258

		}
		return nil, fmt.Errorf("[%s] 创建搜索请求失败: %w", p.Name(), err)
	}

	// 设置完整的请求头
	req.Header.Set("User-Agent", UserAgent)
	req.Header.Set("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8")
	req.Header.Set("Accept-Language", "zh-CN,zh;q=0.9,en;q=0.8")
	req.Header.Set("Connection", "keep-alive")
	req.Header.Set("Upgrade-Insecure-Requests", "1")
	req.Header.Set("Cache-Control", "max-age=0")
	req.Header.Set("Referer", BaseURL+"/")

	resp, err := p.doRequestWithRetry(req, client)
	if err != nil {
		if p.debugMode {
			log.Printf("[DYYJ] 搜索请求失败: %v", err)
		}
		return nil, fmt.Errorf("[%s] 搜索请求失败: %w", p.Name(), err)
	}
	defer resp.Body.Close()

	if p.debugMode {
		log.Printf("[DYYJ] 搜索请求响应状态码: %d", resp.StatusCode)
	}

	if resp.StatusCode != 200 {
		if p.debugMode {
			log.Printf("[DYYJ] 搜索请求HTTP状态错误: %d", resp.StatusCode)
		}
		return nil, fmt.Errorf("[%s] 搜索请求HTTP状态错误: %d", p.Name(), resp.StatusCode)
	}

	// 读取响应体用于调试
	bodyBytes, err := io.ReadAll(resp.Body)
	if err != nil {
		if p.debugMode {

View on GitHub (pinned to beaa561337)