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.
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:
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:
Environment
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.