I’m trying to set up a Telegram bot that works through a Tor proxy connection, but I keep getting timeout errors when attempting to reach the Telegram servers.
The error message I’m seeing looks like this:
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot/getUpdates?offset=1&timeout=20
This happens every time I try to make requests to the Telegram API while routing through Tor. The connection seems to time out before it can establish a proper link to the server. Has anyone else encountered this issue when using pytelegrambotapi with Tor? What might be causing this timeout problem?
torify your whole python script instead of just proxy settings - way easier than messing with pytelegrambotapi’s internal timeout configs. just run torify python your_bot.py and it routes everything automatically. fixed my connection drops completely
Yeah, Tor timeout issues are super common with API calls. Tor’s multiple hops kill your latency, and default timeouts are way too aggressive.
I’ve dealt with this building anonymous bots. Sure, you can manually tweak proxy settings and timeouts in pytelegrambotapi, but it’s a nightmare to maintain.
What actually works? Use an automation platform that handles proxy stuff for you. Skip wrestling with connection pools and retry logic - just set up workflows that manage Tor routing and handle timeouts automatically.
You get built-in error handling, automatic retries with backoff, and can swap proxy configs without touching code. Throw in monitoring and alerts when connections fail.
This beats trying to perfect manual proxy setup every time. Way more reliable in production.
Latenode handles the proxy management and API reliability so you can focus on bot logic: https://latenode.com
Had the exact same problem with my anonymity bot. Tor circuits are just slow and flaky for API calls - pytelegrambotapi’s default timeouts assume you’re connecting directly, not bouncing through multiple Tor nodes. Bump your timeouts way up. I use 60 seconds for connection and 120 for reading responses. You’ll also want exponential backoff retries since Tor drops connections all the time. Here’s what really got me - some Tor exit nodes are straight-up blocked by Telegram. You might need to force specific exit nodes or create fresh circuits when requests fail. The stem library lets you control Tor circuits programmatically. Honestly though, if you don’t need bulletproof anonymity, just use a VPN. Way less hassle and actually works reliably.
Been running bots through Tor for two years and this timeout issue hit me hard at first. It’s not just slow circuits - Telegram’s rate limiting gets way more aggressive when they see requests from sketchy Tor exit nodes. Here’s what fixed it for me: Crank up your timeouts big time - I use 45 seconds for connect and 90 for read. Ditch basic SOCKS proxy and use the requests-tor library instead since it handles connection pooling better. But the real game changer? Rotate circuits every 10-15 API calls using stem library to grab new Tor identities. Bottom line: persistence beats speed with Tor. My bots run for weeks now without me touching them, though they’re definitely slower than direct connections.