chenhg5/cc-connect · error
qqbot: api request failed: %w
Error message
qqbot: api request failed: %w
What it means
apiRequestJSON wraps any transport-level failure from core.HTTPClient.Do with this error. It means the HTTP round trip to the QQ Bot API never completed: DNS failure, connection refused/reset, TLS error, or context timeout. Unlike 4xx/5xx errors, no HTTP response exists, so the raw underlying error is preserved via %w.
Source
Thrown at platform/qqbot/qqbot.go:328
}
bodyReader = bytes.NewReader(data)
}
token, err := p.getAccessToken()
if err != nil {
return fmt.Errorf("qqbot: get token: %w", err)
}
req, err := http.NewRequest(method, url, bodyReader)
if err != nil {
return err
}
req.Header.Set("Authorization", "QQBot "+token)
req.Header.Set("Content-Type", "application/json")
resp, err := core.HTTPClient.Do(req)
if err != nil {
return fmt.Errorf("qqbot: api request failed: %w", err)
}
defer resp.Body.Close()
// Retry once on 401
if resp.StatusCode == http.StatusUnauthorized {
if err := p.refreshToken(); err != nil {
return fmt.Errorf("qqbot: token refresh on 401: %w", err)
}
token, _ = p.getAccessToken()
if body != nil {
data, _ := json.Marshal(body)
bodyReader = bytes.NewReader(data)
}
req2, err := http.NewRequest(method, url, bodyReader)
if err != nil {
return fmt.Errorf("qqbot: build retry request: %w", err)
}View on GitHub (pinned to 4000b2338a)
Solutions
- Read the wrapped error (%w) to distinguish DNS vs connection vs timeout causes.
- Verify outbound network access to the QQ API host (curl the URL from the same machine).
- If behind a proxy, set HTTPS_PROXY appropriately for the process.
- Retry the operation — transient network blips are common; the code does not retry transport failures.
- Check if the request is being cancelled early (context deadline in the caller).
Defensive patterns
Strategy: retry
Validate before calling
url := "https://api.sgroup.qq.com"
if err := net.DialTimeout("tcp", url+":443", 5*time.Second); err != nil {
return fmt.Errorf("qqbot API unreachable from this host: %w", err)
} Try / catch
var netErr net.Error
if errors.As(err, &netErr) && netErr.Timeout() {
// transient: retry with backoff
time.Sleep(backoff)
return p.sendMessage(ctx, replyCtx, text)
} Prevention
- Ensure stable outbound HTTPS access to the QQ API from the host.
- Set proxy env vars explicitly if running behind a corporate proxy.
- Add application-level retry with backoff around send operations.
- Monitor network health; transport failures are always environmental.
When it happens
Trigger: core.HTTPClient.Do returns an error during sendMessage, uploadRichMedia (file upload payload), or ackInteraction — e.g. DNS resolution failure, TCP connect timeout, TLS handshake failure, or request context cancellation while calling the QQ API.
Common situations: Host has no internet access or a restrictive firewall/proxy; QQ API temporarily down; oversized upload body hitting an idle-timeout; corporate proxy requiring configuration not present in the environment.
Related errors
- qqbot: api retry failed: %w
- gateway request failed: %w
- range chunk retries exhausted
- request usage endpoint: %w
- reasonix: POST %s: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/ec8fb5089829fa5e.
Report an issue: GitHub.