Hello,
I’ve been using the Telegram API with my bot for the last 6 months without any issues, but recently, I’ve encountered a problem where the code fails with a timeout error, although the message successfully reaches Telegram. This has been happening for the past few days.
To troubleshoot, I increased the timeout to 60 seconds, but the issue persists. Below is the full traceback:
Traceback (most recent call last): File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 402, in _make_request six.raise_from(e, None) File "<string>", line 2, in raise_from File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 398, in _make_request httplib_response = conn.getresponse() File "/usr/local/lib/python3.9/http/client.py", line 1345, in getresponse response.begin() File "/usr/local/lib/python3.9/http/client.py", line 307, in begin version, status, reason = self._read_status() File "/usr/local/lib/python3.9/http/client.py", line 268, in _read_status line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1") File "/usr/local/lib/python3.9/socket.py", line 704, in readinto return self._sock.recv_into(b) File "/usr/local/lib/python3.9/ssl.py", line 1241, in recv_into return self.read(nbytes, buffer) File "/usr/local/lib/python3.9/ssl.py", line 1099, in read return self._sslobj.read(len, buffer) socket.timeout: The read operation timed out During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/utils/request.py", line 253, in _request_wrapper resp = self._con_pool.request(*args, **kwargs) File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/vendor/ptb_urllib3/urllib3/request.py", line 68, in request return self.request_encode_body(method, url, fields=fields, File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/vendor/ptb_urllib3/urllib3/request.py", line 148, in request_encode_body return self.urlopen(method, url, **extra_kw) File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/vendor/ptb_urllib3/urllib3/poolmanager.py", line 359, in urlopen return super(ProxyManager, self).urlopen(method, url, redirect=redirect, **kw) File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/vendor/ptb_urllib3/urllib3/poolmanager.py", line 244, in urlopen response = conn.urlopen(method, u.request_uri, **kw) File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 665, in urlopen retries = retries.increment(method, url, error=e, _pool=self, File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/vendor/ptb_urllib3/urllib3/util/retry.py", line 347, in increment raise six.reraise(type(error), error, _stacktrace) File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/vendor/ptb_urllib3/urllib3/packages/six.py", line 686, in reraise raise value File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 614, in urlopen httplib_response = self._make_request(conn, method, url, File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 404, in _make_request self._raise_timeout(err=e, url=url, timeout_value=read_timeout, File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/vendor/ptb_urllib3/urllib3/connectionpool.py", line 321, in _raise_timeout raise exc_cls(*args) telegram.vendor.ptb_urllib3.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='api.telegram.org', port=443): Read timed out. (read timeout=60) The above exception was the direct cause of the following exception: Traceback (most recent call last): File "/home/GoldyBot/GBot/GBot.py", line 760, in <module> makeSignal(nowDateTimeUTC) File "/home/GoldyBot/GBot/GBot.py", line 505, in makeSignal messageInfo = bot.send_photo(chat_id = channelID, photo = open(signalImage, "rb"), caption = signalText, parse_mode = "html", timeout = 60) File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/bot.py", line 127, in decorator result = func(*args, **kwargs) File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/bot.py", line 661, in send_photo return self._message( # type: ignore[return-value] File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/bot.py", line 296, in _message result = self._post(endpoint, data, timeout=timeout, api_kwargs=api_kwargs) File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/bot.py", line 259, in _post return self.request.post( File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/utils/request.py", line 348, in post result = self._request_wrapper('POST', url, fields=data, **urlopen_kwargs) File "/home/GoldyBot/.local/lib/python3.9/site-packages/telegram/utils/request.py", line 255, in _request_wrapper raise TimedOut() from error telegram.error.TimedOut: Timed out It seems that while the message is successfully sent to Telegram, the code still throws a timeout error. Could anyone provide insights on what could be causing this issue? I haven't made any changes to the code, and the bot was working fine before.
Any help would be greatly appreciated!