tonhowtf/omniget · error

Edge TTS: conexao recusada

Error message

Edge TTS: conexao recusada ({})

What it means

synth_chunk opens a WebSocket connection to the Edge TTS service via tokio_tungstenite's connect_async. If the handshake fails (connection refused, DNS failure, TLS error), the error is wrapped with this message. It means the TTS service could not be reached at the WebSocket level.

Solutions

  1. Verify network connectivity and that the wss:// speech.platform.bing.com endpoint is reachable
  2. Check proxy/firewall/VPN rules allow outbound WebSocket (wss) connections on 443
  3. Retry with backoff — the service may be temporarily unavailable
  4. Update the library if Microsoft changed the endpoint URL

Example fix

// before
let result = edge_tts::synthesize(&opts, &path, progress).await?;
// after
for attempt in 1..=3 {
    match edge_tts::synthesize(&opts, &path, progress).await {
        Ok(r) => { /* use r */ break; }
        Err(e) if e.to_string().contains("conexao recusada") && attempt < 3 => tokio::time::sleep(Duration::from_secs(attempt * 2)).await,
        Err(e) => return Err(e),
    }
}
Defensive patterns

Strategy: retry

Validate before calling

// cheap connectivity probe before synthesis
let reachable = tokio::net::TcpStream::connect("speech.platform.bing.com:443").await.is_ok();

Try / catch

match edge_tts::synthesize(&opts, &path, progress).await {
    Ok(r) => r,
    Err(e) if e.to_string().contains("conexao recusada") => retry_with_backoff(3, e),
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: Calling synthesize() when the WebSocket endpoint is unreachable: wrong/blocked host, DNS resolution failure, network outage, TLS handshake failure, or proxy blocking wss:// traffic.

Common situations: Offline machine or no internet access; firewall blocking outbound WebSocket connections; Microsoft changing the WSS endpoint; DNS misconfiguration in containers/CI; VPN interfering with TLS.

Understand the failure class

Background: ECONNREFUSED and "connection refused" / "could not connect to server" errors: what they mean and how to fix them — this error's family across 44 libraries.

Related errors


AI-assisted analysis of tonhowtf/omniget@8600b91f42 (2026-09-12). Data as JSON: /api/errors/7b4a7bf437069565. Report an issue: GitHub.

Appendix: source

Thrown at src-tauri/omniget-core/src/core/tools/edge_tts.rs:255

    h.insert("Cache-Control", "no-cache".parse()?);
    h.insert(
        "Origin",
        "chrome-extension://jdiccldimpdaibmpdkjnbmckianbfold".parse()?,
    );
    h.insert("Accept-Encoding", "gzip, deflate, br".parse()?);
    h.insert("Accept-Language", "en-US,en;q=0.9".parse()?);
    h.insert(
        "User-Agent",
        format!(
            "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/{}.0.0.0 Safari/537.36 Edg/{}.0.0.0",
            chromium_major(),
            chromium_major()
        )
        .parse()?,
    );
    let (mut ws, _) = tokio_tungstenite::connect_async(req)
        .await
        .map_err(|e| anyhow!("Edge TTS: conexao recusada ({})", e))?;

    let cfg = format!(
        "X-Timestamp:{}\r\nContent-Type:application/json; charset=utf-8\r\nPath:speech.config\r\n\r\n{{\"context\":{{\"synthesis\":{{\"audio\":{{\"metadataoptions\":{{\"sentenceBoundaryEnabled\":\"false\",\"wordBoundaryEnabled\":\"true\"}},\"outputFormat\":\"audio-24khz-48kbitrate-mono-mp3\"}}}}}}}}\r\n",
        date_string()
    );
    ws.send(Message::Text(cfg.into())).await?;
    let ssml = mkssml(
        &escape_xml(text),
        &opts.voice,
        &opts.rate,
        &opts.pitch,
        &opts.volume,
    );
    let req_id = connect_id();
    let msg = format!(
        "X-RequestId:{}\r\nContent-Type:application/ssml+xml\r\nX-Timestamp:{}Z\r\nPath:ssml\r\n\r\n{}",
        req_id,
        date_string(),

View on GitHub (pinned to 8600b91f42)