babalae/better-genshin-impact · error · NotifierException

Telegram API request timed out. Check your internet…

Error message

Telegram API request timed out. Check your internet connection.

What it means

Wraps TaskCanceledException — fires when the HttpClient request exceeds the 30-second timeout configured in the ctor (or the task is explicitly cancelled). Indicates the request was sent but no timely response arrived.

Solutions

  1. Confirm connectivity to api.telegram.org (or raise the timeout for large image uploads).
  2. If using a proxy, ensure it has adequate bandwidth and is not stalling.
  3. Consider increasing the 30s timeout for sendPhoto payloads.
  4. Implement one retry on TaskCanceledException before reporting failure.

Example fix

// before
_httpClient = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(30) };

// after — longer timeout for image-capable notifier + retry
_httpClient = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(60) };
// and in SendAsync:
// catch (TaskCanceledException) when (!cancellationToken.IsCancellationRequested)
//     => transient timeout, retry once
Defensive patterns

Strategy: retry

Try / catch

for (int attempt = 0; ; attempt++)
try { await telegramNotifier.SendAsync(data); break; }
catch (NotifierException ex) when (ex.Message.Contains("timed out") && attempt < 1)
{ await Task.Delay(TimeSpan.FromSeconds(5)); }

Prevention

When it happens

Trigger: _httpClient.SendAsync does not complete within TimeSpan.FromSeconds(30); the CancellationToken (none passed here) would also surface as TaskCanceledException.

Common situations: Slow/blocked network reaching Telegram; large screenshot upload over a throttled proxy; regional blocking causing TCP hangs; the 30s timeout too low for big images on poor links.

Understand the failure class

Related errors


AI-assisted analysis of babalae/better-genshin-impact@a7cb36712d (2026-08-13). Data as JSON: /api/errors/bc115598cde9d714. Report an issue: GitHub.

Appendix: source

Thrown at BetterGenshinImpact/Service/Notifier/TelegramNotifier.cs:134

        if (string.IsNullOrEmpty(content.Message)) throw new NotifierException("No message content to send");

        try
        {
            if (content.Screenshot != null)
            {
                await SendImageMessageAsync(content.Screenshot, content.Message.Length < 1024 ? content.Message : null);
                if (content.Message.Length < 1024) return;
            }

            await SendTextMessageAsync(content.Message);
        }
        catch (HttpRequestException ex)
        {
            throw new NotifierException("Network error sending Telegram notification: " + ex.Message);
        }
        catch (TaskCanceledException)
        {
            throw new NotifierException("Telegram API request timed out. Check your internet connection.");
        }
        catch (System.Exception ex) when (ex is not NotifierException)
        {
            throw new NotifierException("Error sending Telegram notification: " + ex.Message);
        }
    }

    private async Task SendImageMessageAsync(Image<Rgb24> image, string? caption)
    {
        var endpoint = $"{TelegramApiBaseUrl}{TelegramBotToken}/sendPhoto";
        using var memoryStream = new MemoryStream();
        await image.SaveAsPngAsync(memoryStream);
        memoryStream.Position = 0;

        var content = new MultipartFormDataContent
        {
            { new StreamContent(memoryStream), "photo", "image.png" },
            { new StringContent(TelegramChatId), "chat_id" }

View on GitHub (pinned to a7cb36712d)