SubtitleEdit/subtitleedit · error · HttpRequestException

AllTalk TTS server request timed out. Please check that the

Error message

AllTalk TTS server request timed out. Please check that the server is running.

What it means

HttpRequestException raised when PostAsync to AllTalk throws a TaskCanceledException that is NOT the caller's cancellation token - i.e. the HttpClient timeout fired. Logged and rewrapped so the user sees a timeout-specific message.

Source

Thrown at src/ui/Logic/Download/TtsDownloadService.cs:169

        multipartContent.Add(new StringContent("false"), "autoplay");
        multipartContent.Add(new StringContent("1.0"), "autoplay_volume");

        HttpResponseMessage result;
        try
        {
            // Honor the caller's token - a bulk-generate Cancel used to leave the AllTalk
            // request running to completion.
            result = await _httpClient.PostAsync(Se.Settings.Video.TextToSpeech.AllTalkUrl.TrimEnd('/') + "/api/tts-generate", multipartContent, cancellationToken);
        }
        catch (HttpRequestException ex)
        {
            SeLogger.Error(ex, "AllTalk TTS server connection failed.");
            throw new HttpRequestException("AllTalk TTS server is not reachable. Please check that the server is running.", ex);
        }
        catch (TaskCanceledException ex) when (!cancellationToken.IsCancellationRequested)
        {
            SeLogger.Error(ex, "AllTalk TTS server request timed out.");
            throw new HttpRequestException("AllTalk TTS server request timed out. Please check that the server is running.", ex);
        }

        using (result)
        {
            if (!result.IsSuccessStatusCode)
            {
                var errorBody = await result.Content.ReadAsStringAsync(cancellationToken);
                SeLogger.Error($"AllTalk TTS failed calling API at {_httpClient.BaseAddress}: Status code={result.StatusCode}" + Environment.NewLine + errorBody);
                throw new HttpRequestException($"AllTalk TTS server returned error {(int)result.StatusCode} ({result.StatusCode}).");
            }

            var bytes = await result.Content.ReadAsByteArrayAsync(cancellationToken);
            var resultJson = Encoding.UTF8.GetString(bytes);

            var jsonParser = new SeJsonParser();
            var allTalkOutput = jsonParser.GetFirstObject(resultJson, "output_file_path");
            return allTalkOutput.Replace("\\\\", "\\");
        }

View on GitHub (pinned to 17a9f07487)

Solutions

  1. Confirm the AllTalk server is responsive (try a short test generation).
  2. Increase HttpClient.Timeout for this client if generations legitimately take long.
  3. Check server load / GPU utilization on the AllTalk host.
  4. Verify network throughput between client and server.
Defensive patterns

Strategy: retry

Validate before calling

if (_httpClient.Timeout < TimeSpan.FromSeconds(60))
{
    // AllTalk generations can exceed default timeout; raise it for this client
    _httpClient.Timeout = TimeSpan.FromSeconds(120);
}

Try / catch

try { var audio = await ttsService.GenerateAllTalk(...); }
catch (HttpRequestException ex) when (ex.Message.Contains("timed out"))
{
    // one bounded retry with a longer timeout; if it fails again, surface the message
    _httpClient.Timeout = TimeSpan.FromSeconds(120);
    await ttsService.GenerateAllTalk(...);
}

Prevention

When it happens

Trigger: TaskCanceledException caught with a `when (!cancellationToken.IsCancellationRequested)` filter, meaning the request exceeded the HttpClient.Timeout rather than being user-cancelled.

Common situations: AllTalk server is slow/overloaded, generating a long clip on weak hardware, network latency, or the configured HttpClient.Timeout is too low for the workload.

Understand the failure class

Related errors


AI-assisted analysis of SubtitleEdit/subtitleedit@17a9f07487 (2026-08-13). Data as JSON: /api/errors/dcbb04f04ae20e28. Report an issue: GitHub.