chenhg5/cc-connect · error
cloud_web: register HTTP %d: %s
Error message
cloud_web: register HTTP %d: %s
What it means
The gateway transport's register call to the cloud-web server returned a non-200 HTTP status. The transport POSTs a registration payload (name, project, public_url) to register_url to exchange capabilities; any non-OK response is surfaced with the status code and the first up-to-1MB of the response body. Note Start() only logs this as a warning — the gateway still runs with default capabilities.
Source
Thrown at platform/cloud-web/gateway.go:154
return nil, err
}
req, err := http.NewRequestWithContext(ctx, http.MethodPost, t.registerURL, bytes.NewReader(body))
if err != nil {
return nil, err
}
req.Header.Set("Content-Type", "application/json")
authHTTP(req, t.token)
resp, err := t.client.Do(req)
if err != nil {
return nil, err
}
defer func() { _ = resp.Body.Close() }()
raw, err := io.ReadAll(io.LimitReader(resp.Body, 1<<20))
if err != nil {
return nil, err
}
if resp.StatusCode != http.StatusOK {
return nil, fmt.Errorf("cloud_web: register HTTP %d: %s", resp.StatusCode, string(raw))
}
return parseRegisterAck(raw)
}
func (t *gatewayTransport) authenticate(r *http.Request) bool {
if t.token == "" {
// Fail closed: a gateway transport without a configured token must
// reject all inbound webhooks rather than accept anything. New()
// already enforces a non-empty token; this is a defense-in-depth guard.
return false
}
if auth := r.Header.Get("Authorization"); strings.HasPrefix(auth, "Bearer ") {
return subtle.ConstantTimeCompare([]byte(auth[7:]), []byte(t.token)) == 1
}
if tok := r.Header.Get("X-Cloud-Web-Token"); tok != "" {
return subtle.ConstantTimeCompare([]byte(tok), []byte(t.token)) == 1
}
if tok := r.URL.Query().Get("token"); tok != "" {View on GitHub (pinned to 4000b2338a)
Solutions
- Read the status and body in the error: 401/403 means fix the shared token in config; 404 means fix register_url; 5xx means check the cloud-web server logs.
- Confirm the token in config.toml matches the server's expected bearer token exactly.
- Point register_url at the server's register endpoint (e.g. https://host/register), not the webhook or send path.
- If the server was down, redeploy it and restart cc-connect; remember Start continues with default capabilities so capabilities may be wrong until restart.
Example fix
// config.toml — before register_url = "https://cloud.example.com/webhook" # wrong endpoint, 404 // after register_url = "https://cloud.example.com/register"
Defensive patterns
Strategy: try-catch
Validate before calling
// smoke-test register before Start
resp, err := http.Post(registerURL, "application/json", bytes.NewReader([]byte("{}")))
if err != nil || resp.StatusCode != http.StatusOK {
return fmt.Errorf("register endpoint not healthy (status %d)", resp.StatusCode)
}
resp.Body.Close() Try / catch
if err := platform.Start(ctx, handler); err != nil {
var httpErr interface{ Error() string }
if errors.As(err, &httpErr) && strings.Contains(err.Error(), "register HTTP") {
slog.Warn("gateway register rejected; running with default capabilities", "error", err)
}
return err
} Prevention
- Keep the shared token identical on server and client config
- Point register_url at the register endpoint, not webhook or send paths
- Monitor for the 'gateway register failed' warning at startup — capabilities may be degraded
- Smoke-test the register endpoint with curl after any server redeploy
When it happens
Trigger: POST to the configured register_url returns 401 (bad/missing token), 404 (wrong register_url path), 500 (server error), etc. — anything other than HTTP 200 is treated as failure.
Common situations: Token mismatch between cc-connect and the cloud-web server; register_url pointing at the wrong host/path or at the webhook URL instead of the register endpoint; server deployed behind a proxy that returns 404/502; server-side auth rotation after a token change.
Understand the failure class
Background: "API error: {status}" and "HTTP 401/403/404/429/5xx" errors: non-2xx HTTP responses explained — this error's family across 27 libraries.
Related errors
- cloud_web: register HTTP %d: %s
- cloud_web: register rejected: %s
- cloud_web: register rejected
- init failed: %w
- begin failed: %w
AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06).
Data as JSON: /api/errors/e54d542ad1ec2329.
Report an issue: GitHub.