K
K
KOSMOS312019-02-10 12:30:37
Telegram
KOSMOS31, 2019-02-10 12:30:37

Telegram bot gives an error on startup, how to fix it?

raceback (most recent call last):
File "main.py", line 682, in
bot.delete_webhook()
File "D:\Python\lib\site-packages\telebot\__init__.py", line 228, in delete_webhook
return apihelper.delete_webhook(self.token)
File "D:\Python\lib\site-packages\telebot\apihelper.py", line 160, in delete_webhook
return _make_request(token, method_url)
File "D:\Python\lib\site -packages\telebot\apihelper.py", line 54, in _make_request
timeout=(connect_timeout, read_timeout), proxies=proxy)
File "D:\Python\lib\site-packages\requests\sessions.py", line 475, in request
resp = self.send(prep, **send_kwargs)
File "D:\Python\lib\site-packages\requests\sessions.py", line 585, in send
r = adapter.send(request, **kwargs)
File "D:\Python\lib\site-packages\requests\adapters.py", line 467, in send
raise ConnectionError(e, request=request)
requests.exceptions. ConnectionError: HTTPSConnectionPool(host='api.telegram.org', port=443): Max retries exceeded with url: /bot297175576:AAFX44Xop-l2tx6uCKKt7HJt2HF2YK-Vek4/deleteWebhook (Caused by NewConnectionError(': Failed to establish a new connection: [ WinError 10061] Connection failed because the destination computer refused the connection request'))

Answer the question

In order to leave comments, you need to log in

5 answer(s)
I
Igor Borisov, 2019-02-10
@khh1

RKN, probably

O
Oleg, 2019-02-10
@OlegPyatakov

I am sure that the problem is in Telegram blocking on the territory of the Russian Federation.
Possible solutions:

  • Use a VPN
  • Use Proxy (needs socks with SSL, may need to disable certificate verification)
  • Host a bot on a foreign cloud

S
SidVisceos, 2019-02-15
@SidVisceos

If the bot is running on the local machine -> proxy or VPN (I used tor).
If the bot is spinning on a hosting -> rent a foreign hosting.

D
Danil K., 2019-06-07
@Danya_Violet

import telebot
from telebot import apihelper

bot = telebot.TeleBot(TOKEN)
apihelper.proxy = {'https': 'socks5h://user:[email protected]:1080'}

in socks5:// documentation, try socks5 h ://

Z
ZvukStyle, 2020-05-16
@ZvukStyle

I see that the topic is old, but after a long search, this helped me:
in the telebot library in the apihelper.py file, change the connection
from https://api.telegram.org/file/bot{0}/{1}
to https:// telegg.ru/orig/bot{0}/{1} I
found the solution already in youtube deep under the video in the comments)
I hope it will help someone else!

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question