fish2018/pansou · error

二维码请求返回状态码

Error message

二维码请求返回状态码: %d

What it means

generateQRCodeWithSig in plugin/qqpd checks the HTTP status of the QR-code image endpoint and rejects any non-200 response with the actual status code embedded. It is a guard against serving corrupted/absent QR images to the login flow; callers handleGetStatus and handleRefreshQRCode will surface this to the user as a QR-code fetch failure.

Solutions

  1. Check the embedded status code: 403/429 means the client IP is blocked or rate-limited — wait and retry, or use a proxy/rotating exit IP.
  2. Retry generateQRCodeWithSig (via handleRefreshQRCode) after a short backoff for transient 5xx codes.
  3. Verify the QR-code endpoint URL and that required headers/cookies are still valid (endpoint may have changed server-side).
  4. Update the plugin if the upstream API contract changed.

Example fix

// before
resp, err := client.Get(qrURL)
...
// after — retry on transient statuses
for attempt := 0; attempt < 3; attempt++ {
    resp, err := client.Get(qrURL)
    if err == nil {
        if resp.StatusCode == 200 {
            break
        }
        resp.Body.Close()
    }
    time.Sleep(time.Duration(attempt+1) * time.Second)
}
Defensive patterns

Strategy: retry

Try / catch

results, err := generateQRCodeWithSig(...)
if err != nil {
    if strings.Contains(err.Error(), "状态码: 429") || strings.Contains(err.Error(), "状态码: 403") {
        time.Sleep(2 * time.Second)
        // retry once, else surface to user as "QR fetch blocked, try later"
    }
}

Prevention

When it happens

Trigger: The GET request to the QQ PD QR-code endpoint returns a status code other than 200 (e.g. 403 anti-bot block, 429 rate limit, 502/503 upstream outage).

Common situations: Server-side rate limiting after repeated QR refreshes; the QQ endpoint changing or blocking datacenter IPs; transient upstream errors during QR refresh loops.

Related errors


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

Appendix: source

Thrown at plugin/qqpd/qqpd.go:2086

// generateQRCodeWithSig 生成QQ登录二维码并返回qrsig
func (p *QQPDPlugin) generateQRCodeWithSig() ([]byte, string, error) {
	qrcodeURL := "https://xui.ptlogin2.qq.com/ssl/ptqrshow?appid=1600001587&e=2&l=M&s=3&d=72&v=4&t=0.3680011491059967&daid=823&pt_3rd_aid=0"

	client := &http.Client{
		Timeout: 15 * time.Second,
		Transport: &http.Transport{
			TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
		},
	}

	resp, err := client.Get(qrcodeURL)
	if err != nil {
		return nil, "", fmt.Errorf("请求二维码失败: %w", err)
	}
	defer resp.Body.Close()

	if resp.StatusCode != 200 {
		return nil, "", fmt.Errorf("二维码请求返回状态码: %d", resp.StatusCode)
	}

	// 读取二维码图片
	qrcodeBytes, err := ioutil.ReadAll(resp.Body)
	if err != nil {
		return nil, "", fmt.Errorf("读取二维码失败: %w", err)
	}

	// 提取qrsig(用于后续登录检测)
	setCookie := resp.Header.Get("Set-Cookie")
	qrsig := extractQrsig(setCookie)
	if qrsig != "" && DebugLog {
		fmt.Printf("[QQPD] 二维码生成成功,qrsig: %s\n", qrsig[:20]+"...")
	}

	return qrcodeBytes, qrsig, nil
}

View on GitHub (pinned to beaa561337)