{"record":{"id":"7b4a7bf437069565","repo":"tonhowtf/omniget","slug":"edge-tts-conexao-recusada","errorCode":null,"errorMessage":"Edge TTS: conexao recusada ({})","messagePattern":"Edge TTS: conexao recusada \\((.+?)\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src-tauri/omniget-core/src/core/tools/edge_tts.rs","lineNumber":255,"sourceCode":"    h.insert(\"Cache-Control\", \"no-cache\".parse()?);\n    h.insert(\n        \"Origin\",\n        \"chrome-extension://jdiccldimpdaibmpdkjnbmckianbfold\".parse()?,\n    );\n    h.insert(\"Accept-Encoding\", \"gzip, deflate, br\".parse()?);\n    h.insert(\"Accept-Language\", \"en-US,en;q=0.9\".parse()?);\n    h.insert(\n        \"User-Agent\",\n        format!(\n            \"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\",\n            chromium_major(),\n            chromium_major()\n        )\n        .parse()?,\n    );\n    let (mut ws, _) = tokio_tungstenite::connect_async(req)\n        .await\n        .map_err(|e| anyhow!(\"Edge TTS: conexao recusada ({})\", e))?;\n\n    let cfg = format!(\n        \"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\",\n        date_string()\n    );\n    ws.send(Message::Text(cfg.into())).await?;\n    let ssml = mkssml(\n        &escape_xml(text),\n        &opts.voice,\n        &opts.rate,\n        &opts.pitch,\n        &opts.volume,\n    );\n    let req_id = connect_id();\n    let msg = format!(\n        \"X-RequestId:{}\\r\\nContent-Type:application/ssml+xml\\r\\nX-Timestamp:{}Z\\r\\nPath:ssml\\r\\n\\r\\n{}\",\n        req_id,\n        date_string(),","sourceCodeStart":237,"sourceCodeEnd":273,"githubUrl":"https://github.com/tonhowtf/omniget/blob/8600b91f4246848bac346874daa9e61c1fc5677a/src-tauri/omniget-core/src/core/tools/edge_tts.rs#L237-L273","documentation":"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.","triggerScenarios":"Calling synthesize() when the WebSocket endpoint is unreachable: wrong/blocked host, DNS resolution failure, network outage, TLS handshake failure, or proxy blocking wss:// traffic.","commonSituations":"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.","solutions":["Verify network connectivity and that the wss:// speech.platform.bing.com endpoint is reachable","Check proxy/firewall/VPN rules allow outbound WebSocket (wss) connections on 443","Retry with backoff — the service may be temporarily unavailable","Update the library if Microsoft changed the endpoint URL"],"exampleFix":"// before\nlet result = edge_tts::synthesize(&opts, &path, progress).await?;\n// after\nfor attempt in 1..=3 {\n    match edge_tts::synthesize(&opts, &path, progress).await {\n        Ok(r) => { /* use r */ break; }\n        Err(e) if e.to_string().contains(\"conexao recusada\") && attempt < 3 => tokio::time::sleep(Duration::from_secs(attempt * 2)).await,\n        Err(e) => return Err(e),\n    }\n}","handlingStrategy":"retry","validationCode":"// cheap connectivity probe before synthesis\nlet reachable = tokio::net::TcpStream::connect(\"speech.platform.bing.com:443\").await.is_ok();","typeGuard":null,"tryCatchPattern":"match edge_tts::synthesize(&opts, &path, progress).await {\n    Ok(r) => r,\n    Err(e) if e.to_string().contains(\"conexao recusada\") => retry_with_backoff(3, e),\n    Err(e) => return Err(e),\n}","preventionTips":["Retry with exponential backoff on connection errors","Check network/proxy/VPN before batch TTS jobs","Monitor Microsoft endpoint changes and keep the library updated"],"tags":["network","websocket","edge-tts","connection"],"backgroundTag":"connection-refused","analyzedSha":"8600b91f4246848bac346874daa9e61c1fc5677a","analyzedAt":"2026-09-12T14:29:19.317Z","contentChangedAt":"2026-09-12T14:29:19.317Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}