chenhg5/cc-connect · warning
二维码多次过期,请重试 setup
Error message
二维码多次过期,请重试 setup
What it means
While polling the QR login status, an "expired" status triggers a QR refresh; the flow allows at most weixinMaxQRRefresh refreshes. Exceeding that budget aborts with the Chinese message "二维码多次过期,请重试 setup" ("QR code expired too many times, please retry setup"). It means nobody scanned the code within its validity window repeatedly.
Source
Thrown at cmd/cc-connect/weixin.go:337
fmt.Printf("QR code updated at: %s\n\n", opts.QRImage)
}
}
time.Sleep(time.Second)
continue
}
time.Sleep(time.Second)
continue
case "scaned":
if !scannedPrinted {
fmt.Println("\n已扫码,请在手机上确认登录…")
scannedPrinted = true
}
time.Sleep(time.Second)
continue
case "expired":
refreshCount++
if refreshCount > weixinMaxQRRefresh {
return nil, fmt.Errorf("二维码多次过期,请重试 setup")
}
fmt.Printf("\n二维码已过期,正在刷新 (%d/%d)…\n", refreshCount, weixinMaxQRRefresh)
newQR, err := weixinFetchBotQRCode(ctx, opts.APIBaseURL, botType, opts.RouteTag, opts.Debug)
if err != nil {
return nil, fmt.Errorf("refresh QR: %w", err)
}
qrKey = newQR.QRCode
qrFetchedAt = time.Now()
scannedPrinted = false
newURL := strings.TrimSpace(newQR.QRCodeImgContent)
if newURL != "" {
fmt.Println("请扫描新二维码:")
fmt.Printf("URL: %s\n\n", newURL)
tryPrintTerminalQRCode(newURL)
}
// 过期刷新时同步更新 QR 图片文件
if opts.QRImage != "" {
if err := saveQRCodeImage(newURL, opts.QRImage); err != nil {View on GitHub (pinned to 4000b2338a)
Solutions
- Re-run `cc-connect weixin setup` and scan the new QR promptly.
- Have the WeChat account and scanning device ready before starting the setup.
- If the terminal QR is unreadable, open the printed URL on another screen and scan from there.
- Increase weixinMaxQRRefresh in the source if longer sessions are needed, or add a prompt before each refresh.
- Use `cc-connect weixin bind --token ...` instead if you already have a token, bypassing the QR flow entirely.
Example fix
// before const weixinMaxQRRefresh = 3 // after const weixinMaxQRRefresh = 10
Defensive patterns
Strategy: retry
Validate before calling
// Ensure a scanner is ready before starting:
if !interactiveTerminal() {
return errors.New("QR login needs an interactive terminal; use weixin bind --token instead")
} Try / catch
if _, err := runWeixinQRLoginFlow(ctx, opts); err != nil {
if strings.Contains(err.Error(), "二维码多次过期") {
fmt.Println("QR expired too many times — rerun setup and scan promptly, or bind with a token")
}
} Prevention
- Scan the QR within its validity window; don't leave setup unattended
- Use `weixin bind --token` when interactive scanning is impractical
- Enlarge the terminal or use the printed URL if terminal QR is hard to scan
- Raise weixinMaxQRRefresh for slow humans or training sessions
When it happens
Trigger: `cc-connect weixin setup` QR flow: the user does not scan the QR before each expiry, refreshCount exceeds weixinMaxQRRefresh, and the poll loop returns this error instead of refreshing again.
Common situations: User walks away and misses the QR window; QR displayed in a non-interactive SSH session; terminal QR rendering too small/blurred to scan; slow human response on a short expiry interval.
Understand the failure class
Background: Request timed out: what client-side request timeouts mean across libraries (Request timed out, TIMED_OUT, APITimeoutError) — this error's family across 39 libraries.
Related errors
- empty qrcode_img_content from server
- refresh QR: %w
- 等待扫码超时,请重试
- get_qrcode_status http %d: %s
- weixin: %s: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/dcbb14f09f4c7f56.
Report an issue: GitHub.