我有一个电报漫游器,但是随着时间的流逝或启动后立即出现连接错误。要编写机器人,我使用“ telebot”库。
requests.exceptions.ConnectTimeout: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bottoken/getUpdates?offset=1&timeout=20 (Caused by ConnectTimeoutError(<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x02FB6910>, 'Connection to api.telegram.org timed out. (connect timeout=3.5)'))
如何处理此错误并尝试打开机器人,直到它打开?
答案 0 :(得分:1)
尝试以下操作-使用ConnectionError
中的requests.eceptions
from requests.exceptions import ConnectionError
try:
Bot working and doing stuff
except ConnectionError as e:
log e
start Bot()