chenhg5/cc-connect · error

qwen tts: request: %w

Error message

qwen tts: request: %w

What it means

Synthesize executes the HTTP POST via q.Client.Do(req). If the request cannot be completed at the transport level (DNS failure, connection refused, TLS error, timeout, context cancellation) the error is wrapped as 'qwen tts: request'. The TTS call never received an HTTP response.

Source

Thrown at core/tts.go:148

	if opts.LanguageType != "" {
		input["language_type"] = opts.LanguageType
	}
	reqBody["input"] = input
	jsonData, err := json.Marshal(reqBody)
	if err != nil {
		return nil, "", fmt.Errorf("qwen tts: marshal request: %w", err)
	}

	req, err := http.NewRequestWithContext(ctx, http.MethodPost, q.BaseURL, bytes.NewReader(jsonData))
	if err != nil {
		return nil, "", fmt.Errorf("qwen tts: create request: %w", err)
	}
	req.Header.Set("Authorization", "Bearer "+q.APIKey)
	req.Header.Set("Content-Type", "application/json")

	resp, err := q.Client.Do(req)
	if err != nil {
		return nil, "", fmt.Errorf("qwen tts: request: %w", err)
	}
	defer resp.Body.Close()

	body, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, "", fmt.Errorf("qwen tts: read response: %w", err)
	}
	if resp.StatusCode != http.StatusOK {
		return nil, "", fmt.Errorf("qwen tts API %d: %s", resp.StatusCode, body)
	}

	var result struct {
		Code    string `json:"code"`
		Message string `json:"message"`
		Output  struct {
			Audio struct {
				URL string `json:"url"`
			} `json:"audio"`

View on GitHub (pinned to 4000b2338a)

Solutions

  1. Check network connectivity/DNS to the TTS host (curl the BaseURL).
  2. Inspect the wrapped error: context.DeadlineExceeded means raise the client timeout or check the caller's context.
  3. Configure proxy env vars (HTTPS_PROXY) if behind a corporate proxy.
  4. Implement a retry with backoff for transient transport errors.
  5. Verify TLS: system root certs present and clock correct.

Example fix

// before
client := &http.Client{} // no timeout, fails cryptically
// after
client := &http.Client{Timeout: 60 * time.Second}
// and on failure: if errors.Is(err, context.DeadlineExceeded) { /* retry with backoff */ }
Defensive patterns

Strategy: retry

Validate before calling

// probe before user-facing use
req, _ := http.NewRequestWithContext(ctx, http.MethodGet, strings.TrimSuffix(q.BaseURL, "/"), nil)
if _, err := q.Client.Do(req); err != nil {
    slog.Warn("tts endpoint unreachable", "err", err)
}

Try / catch

var audio []byte
var err error
for i := 0; i < 3; i++ {
    audio, _, err = q.Synthesize(ctx, text, opts)
    if err == nil || !isTransportError(err) { break }
    time.Sleep(time.Duration(1<<i) * time.Second)
}
if err != nil && strings.Contains(err.Error(), "qwen tts: request") {
    return fmt.Errorf("TTS service unreachable: %w", err)
}

Prevention

When it happens

Trigger: q.Client.Do returns a non-nil error: network unreachable, DNS resolution failure, proxy misconfiguration, TLS handshake failure, deadline exceeded via ctx, or client.Timeout firing.

Common situations: No internet or firewalled egress to the Dashscope endpoint; corporate proxy required but unset; API host outage; context cancelled because the user's messaging session timed out; http.Client with too-short a timeout for long synthesis jobs.

Related errors


AI-assisted analysis of chenhg5/cc-connect@4000b2338a (2026-09-06). Data as JSON: /api/errors/379c10ca888815bb. Report an issue: GitHub.