chenhg5/cc-connect · error
weibo: ws dial: %w
Error message
weibo: ws dial: %w
What it means
websocket.DefaultDialer.DialContext failed to establish the WebSocket connection to the Weibo realtime endpoint (network unreachable, DNS failure, expired/invalid token in the query string, or server refusal). connectLoop retries this with exponential backoff up to maxReconnect.
Source
Thrown at platform/weibo/weibo.go:262
defer p.connMu.Unlock()
tok, err := p.getToken()
if err != nil {
return err
}
u, err := url.Parse(p.wsEndpoint)
if err != nil {
return fmt.Errorf("weibo: parse ws endpoint: %w", err)
}
q := u.Query()
q.Set("app_id", p.appID)
q.Set("token", tok)
u.RawQuery = q.Encode()
ws, _, err := websocket.DefaultDialer.DialContext(p.ctx, u.String(), nil)
if err != nil {
return fmt.Errorf("weibo: ws dial: %w", err)
}
p.wsMu.Lock()
if p.ws != nil {
p.ws.Close()
}
p.ws = ws
p.wsMu.Unlock()
slog.Info(p.tag() + ": websocket connected")
go p.pingLoop(ws)
p.readLoop(ws)
return nil
}
func (p *Platform) pingLoop(ws *websocket.Conn) {
ticker := time.NewTicker(pingInterval)View on GitHub (pinned to 4000b2338a)
Solutions
- Check network connectivity and DNS resolution to the Weibo ws endpoint
- If the handshake returns 401/403, force a token refresh (getToken) before dialing, since the token query param may be stale
- Rely on connectLoop's exponential backoff for transient outages; investigate logs if it never recovers
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at platform/weibo/weibo.go:262 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/06975a7f595e8959.
Report an issue: GitHub.