Host api telegram org port 443

Возникла проблема с запуском бота с помощью Proxy:
В инете нашел 2 варианта использования Proxy в PyTelegramBotApi:
1) http proxy

При использовании данного способа выходит следуйщая ошибка:

Также есть метод с использованием SOCKS5

Но он тоже не работает :

Эти способы взяты из документации . Все модули обновлены .

2) Способ с использованием Socket

После которого не работает локальная БД(Mysql).

В боте прописано это
while True:

except Exception as e:

time.sleep(15)

Comments

Copy link Quote reply

vashchukmaksim commented Jul 5, 2018 •

Packages:
pyTelegramBotAPI==3.6.3
requests==2.19.1
PySocks==1.6.8
urllib3==1.23

OS: MacOS or Ubuntu 16 (via docker)

Python: Python 3.5.3 or PyPy3 (also 3.5.3)

Problem:
I successfully ran a bot some hours ago but after some time it starts to throw an error. I have to use a proxy (and it worked with a proxy at the beginning). I tried HTTPS, SOCKS5 proxies and I’m sure that they are working ones but I still get this error and I suppose that Telegram servers are fine right now. There are many posts in the internet with the same error but they have no information and solutions to the problem (beside the fact that people switch to some other packages).

Don’t know if this is a bug or not, but as there are no answers in other places I decided to put it here.

Code:

Traceback:

UPD:

Tried my former code that uses python-telegram-bot with the same TG_PROXY and TG_BOT_TOKEN and everything works ok. So it’s not a proxy / telegram servers or "ban" problem.

This comment has been minimized.

Copy link Quote reply

M1LKYWVY commented Jul 5, 2018 •

@vashchukmaksim
I had similar problem. One of the solutions of this problem can be increasing timeout value in polling function. I use value ‘123’ and everything is ok.
bot.polling(none_stop=True, timeout=123

This comment has been minimized.

Copy link Quote reply

vashchukmaksim commented Jul 6, 2018 •

@M1LKYWVY Unfortunately it didn’t help. And actually I got a strange behaviour right now. If I set timeout to 123, it crashes with 409 error because thinks that multiple getUpdates running. If I remove while cycle (and keep 123 timeout) it repeats the initial error. Also if I remove polling and trying to call just bot.get_me() it still crashes with the initial error.

This comment has been minimized.

Copy link Quote reply

vashchukmaksim commented Jul 6, 2018

I simplified everything just to:

bot.py

app.py

I tried to turn off a proxy since on my current network I can use telegram directly but I still get the same error (and with proxy enabled I still got the same)

This comment has been minimized.

Copy link Quote reply

vashchukmaksim commented Jul 6, 2018

Hm, I think I found out a problem but I don’t know how to solve it. The case I suppose in setting a proxy because when I tried to access a telegram.org in the browser I got an SSL error, and when I turn on a VPN it works.

So now I think that telebot just ignores apihelper.proxy = <‘http’: TG_PROXY>and don’t know how to make it use a proxy.

This comment has been minimized.

Copy link Quote reply

Onefivefournine commented Jul 15, 2018

Found solution here, thanks for @kostykoff
#499 (comment)
You just need to install version 2.10.0 of requests

This comment has been minimized.

Copy link Quote reply

mrkeuz commented Oct 15, 2018

@Onefivefournine sorry, but receipt does not work properly

This comment has been minimized.

Copy link Quote reply

keshamin commented Oct 28, 2018

Experiening the same issue.
The environment is:

Оцените статью
Много толка
Добавить комментарий