Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bot is suddenly crashing #473

Closed
CyberWenger opened this issue Mar 12, 2018 · 7 comments
Closed

Bot is suddenly crashing #473

CyberWenger opened this issue Mar 12, 2018 · 7 comments

Comments

@CyberWenger
Copy link

  1. What version of pyTelegramBotAPI are you using?
    - Latest

  2. What OS are you using?
    - Ubuntu

  3. What version of python are you using?
    - 3.4

Hi, Dear Community
Just want to say that I'm a novice and do not know very well both in programming and in the etiquette you have, so please forgive me in advance

I have a small bot with simple functions. It works well, but sometimes it crashed. After starting it always works for a while (always in different ways, it can work 40 hours or 2 hours) and then stops responding. I've been trying to solve this problem for more than a week, I've tried so many ways that I forgot even what I used

Remember I was getting this error
File "/lebot/telebot/util.py", line 58, in run task(*args, **kwargs) File "/lebot/telebot/__init__.py", line 159, in __retrieve_updates updates = self.get_updates(offset=(self.last_update_id + 1), timeout=timeout) File "/lebot/telebot/__init__.py", line 129, in get_updates json_updates = apihelper.get_updates(self.token, offset, limit, timeout, allowed_updates) File "/lebot/telebot/apihelper.py", line 175, in get_updates return _make_request(token, method_url, params=payload) File "/lebot/telebot/apihelper.py", line 54, in _make_request timeout=(connect_timeout, read_timeout), proxies=proxy) File "/usr/local/lib/python3.4/dist-packages/requests/sessions.py", line 508, in request resp = self.send(prep, **send_kwargs) File "/usr/local/lib/python3.4/dist-packages/requests/sessions.py", line 618, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python3.4/dist-packages/requests/adapters.py", line 521, in send raise ReadTimeout(e, request=request) requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='api.telegram.org', port=443): Read timed out. (read timeout=30)

Then I tried this solution #401
And then I stopped getting error reports in screen -list, only got this message:
There is no screen to be resumed matching 31786.mybot.

I also tried other solutions, but bot crushed sooner or later anyway

If necessary, I can give the bot code that I uploaded to the hosting

@VoidDruid
Copy link

I'm having the same issue, had not figured it out yet.

@David-Lor
Copy link
Contributor

That's a common issue, I suppose is something related with Telegram servers? You can somehow """fix""" the problem putting the polling inside a while True loop, so when it fails, it'll restart automatically. Here I uploaded some examples: https://gist.github.com/EnforcerZhukov/37e0ae02cd7fb1cd01085b2de553dde4

@sviat9440
Copy link
Contributor

sviat9440 commented Apr 2, 2018

bot.polling(none_stop=True)

@David-Lor
Copy link
Contributor

none_stop=True usually does nothing about the timeout errors and other errors, at least in all my bots

@sviat9440
Copy link
Contributor

@EnforcerZhukov ok, soon I will try to fix this problem.

@sviat9440
Copy link
Contributor

sviat9440 commented Apr 3, 2018

It's a lot harder than I thought. Back to while True :)

@sviat9440
Copy link
Contributor

Try bot.infinity_polling()
Works three days without crash, with unstable Internet

MrUpyachka pushed a commit to MrUpyachka/bothometh that referenced this issue Feb 2, 2021
Strong language removed
Default INFO logging
Logging dev mode switch attempts
Bonk added. J
Reply criteria fixed

Logging and simple reply for our own messages
Bot crash fix
eternnoir/pyTelegramBotAPI#473
Help message fix
Stickers logging added
pip file added for ref
Commands handling reworked to support mapping from JSON
Direct message with dev mode enabled to print sticker details
Settings moved to file and generic replies support
MrUpyachka added a commit to MrUpyachka/bothometh that referenced this issue Feb 2, 2021
Strong language removed
Default INFO logging
Logging dev mode switch attempts
Bonk added. J
Reply criteria fixed

Logging and simple reply for our own messages
Bot crash fix
eternnoir/pyTelegramBotAPI#473
Help message fix
Stickers logging added
pip file added for ref
Commands handling reworked to support mapping from JSON
Direct message with dev mode enabled to print sticker details
Settings moved to file and generic replies support
MrUpyachka added a commit to MrUpyachka/bothometh that referenced this issue Feb 2, 2021
Strong language removed
Default INFO logging
Logging dev mode switch attempts
Bonk added. J
Reply criteria fixed

Logging and simple reply for our own messages
Bot crash fix
eternnoir/pyTelegramBotAPI#473
Help message fix
Stickers logging added
pip file added for ref
Commands handling reworked to support mapping from JSON
Direct message with dev mode enabled to print sticker details
Settings moved to file and generic replies support
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants