hermes - 💡(How to fix) Fix Telegram polling fails when DoH returns same IP as system DNS [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
NousResearch/hermes-agent#14520Fetched 2026-04-24 06:16:47
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Participants
Timeline (top)
labeled ×4

Root Cause

In `gateway/platforms/telegram_network.py` around line 210, the code excludes system DNS IPs from the fallback candidates:

if ip not in seen and ip not in system_ips:

When DoH (DNS-over-HTTPS) returns the same IP as the system resolver, that IP is incorrectly filtered out. In many network environments, the system DNS result is actually the most reliable path to api.telegram.org, so excluding it causes fallback to hardcoded IPs that may not be routable.

Fix Action

Fix

Remove the system_ips exclusion, keeping only the deduplication logic:

# Before
if ip not in seen and ip not in system_ips:

# After  
if ip not in seen:

Code Example

if ip not in seen and ip not in system_ips:

---

# Before
if ip not in seen and ip not in system_ips:

# After  
if ip not in seen:
RAW_BUFFERClick to expand / collapse

Bug Description

Telegram Bot API polling fails intermittently due to a bug in `telegram_network.py` `discover_fallback_ips()` function.

Root Cause

In `gateway/platforms/telegram_network.py` around line 210, the code excludes system DNS IPs from the fallback candidates:

if ip not in seen and ip not in system_ips:

When DoH (DNS-over-HTTPS) returns the same IP as the system resolver, that IP is incorrectly filtered out. In many network environments, the system DNS result is actually the most reliable path to api.telegram.org, so excluding it causes fallback to hardcoded IPs that may not be routable.

Fix

Remove the system_ips exclusion, keeping only the deduplication logic:

# Before
if ip not in seen and ip not in system_ips:

# After  
if ip not in seen:

Environment

  • Affected: Multiple users in regions with unstable routing to Telegram servers
  • Not region-specific — can occur whenever DoH and system DNS return overlapping results

Verification

After the fix, the connection uses the correct reachable IP (verified via lsof: `TCP -> 149.154.166.110:443 ESTABLISHED`) instead of falling back to an unreachable hardcoded IP.

extent analysis

TL;DR

Remove the system IPs exclusion in the discover_fallback_ips() function to prevent incorrect filtering of reliable DNS results.

Guidance

  • Identify the discover_fallback_ips() function in telegram_network.py and locate the line excluding system DNS IPs.
  • Remove the ip not in system_ips condition to keep only the deduplication logic, as shown in the provided fix.
  • Verify the change by checking the connection IP using lsof and ensuring it uses the correct reachable IP.
  • Test the updated code in different network environments to confirm the fix resolves the intermittent polling failures.

Example

# Updated code
if ip not in seen:
    # ... (rest of the function remains the same)

Notes

This fix assumes that the system DNS result is a reliable path to api.telegram.org in most network environments. However, this may not be the case in all scenarios, and additional testing may be necessary to ensure the fix works as expected.

Recommendation

Apply the workaround by removing the system IPs exclusion, as it directly addresses the identified root cause and has been verified to resolve the issue.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

hermes - 💡(How to fix) Fix Telegram polling fails when DoH returns same IP as system DNS [1 participants]