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 stop responding #7

Closed
Xh0st opened this issue Jun 15, 2021 · 13 comments
Closed

Bot stop responding #7

Xh0st opened this issue Jun 15, 2021 · 13 comments
Labels
help wanted Extra attention is needed

Comments

@Xh0st
Copy link

Xh0st commented Jun 15, 2021

Bot stop interacting after been inactive. If not used for a while bot it's not responding. I have to close the terminal and run'it again.

@fabston
Copy link
Owner

fabston commented Jun 15, 2021

You have to either use systemd or PM2 to run it clienteles. For more take a look here.

@fabston fabston closed this as completed Jun 15, 2021
@fabston fabston added the help wanted Extra attention is needed label Jun 15, 2021
@Xh0st
Copy link
Author

Xh0st commented Jun 17, 2021

Runing the script with pm2 and after some time still stop responding. This is the bot_log from pm2

Traceback (most recent call last):
File "/home/gargamel/airdrop/main.py", line 307, in
bot.polling()
File "/home/gargamel/.local/lib/python3.8/site-packages/telebot/init.py", line 514, in polling
self.__threaded_polling(none_stop, interval, timeout, long_polling_timeout)
File "/home/gargamel/.local/lib/python3.8/site-packages/telebot/init.py", line 573, in __threaded_polling
raise e
File "/home/gargamel/.local/lib/python3.8/site-packages/telebot/init.py", line 536, in __threaded_polling
self.worker_pool.raise_exceptions()
File "/home/gargamel/.local/lib/python3.8/site-packages/telebot/util.py", line 117, in raise_exceptions
raise self.exception_info
File "/home/gargamel/.local/lib/python3.8/site-packages/telebot/util.py", line 69, in run
task(*args, **kwargs)
File "/home/gargamel/airdrop/main.py", line 154, in handle_text
bot.send_message(message.chat.id,
File "/home/gargamel/.local/lib/python3.8/site-packages/telebot/init.py", line 768, in send_message
apihelper.send_message(self.token, chat_id, text, disable_web_page_preview, reply_to_message_id,
File "/home/gargamel/.local/lib/python3.8/site-packages/telebot/apihelper.py", line 225, in send_message
return _make_request(token, method_url, params=payload, method='post')
File "/home/gargamel/.local/lib/python3.8/site-packages/telebot/apihelper.py", line 126, in _make_request
result = _get_req_session().request(
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3/dist-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3/dist-packages/requests/adapters.py", line 498, in send
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', OSError("(110, 'ETIMEDOUT')"))

@fabston
Copy link
Owner

fabston commented Jun 17, 2021

Do you run the bot on a VPS? Because it looks like a network problem.

You can try the following. Replace bot.polling() in main.py with:

  try:
    bot.polling()
  except OSError:
    print("Connection Error. Reconnecting...")
    time.sleep(1)
    bot.polling()

@Xh0st
Copy link
Author

Xh0st commented Jun 17, 2021

Yes it's runing on a VPS. I will lett you know if this is working.

@fabston
Copy link
Owner

fabston commented Jun 17, 2021

I just edited the message. You might want to include the print statement.

@Xh0st
Copy link
Author

Xh0st commented Jun 17, 2021

still same issue. I have two bots running on azure and only this one it's sleeping after a period of time.

@fabston
Copy link
Owner

fabston commented Jun 17, 2021

Odd, never happened to me and I am also not able to reproduce it.

@Xh0st
Copy link
Author

Xh0st commented Jun 17, 2021

I have setup an script and sending /start command to the bot every 5 minutes and it's working now, not going to sleep anymore.

@fabston
Copy link
Owner

fabston commented Jun 17, 2021

What a pita. But if it works.

@Xh0st
Copy link
Author

Xh0st commented Jun 20, 2021

What a pita. But if it works.

on my raspberry pi it's working perfectly but on azure it's going to sleep. Solved this issue for myself by disabling threading
bot = telebot.TeleBot(config.token, threaded=False)

@fabston
Copy link
Owner

fabston commented Jun 20, 2021

Interesting. Are you using the bot behind a Webhook now and it still goes into sleep?

@Xh0st
Copy link
Author

Xh0st commented Jun 20, 2021

Interesting. Are you using the bot behind a Webhook now and it still goes into sleep?

I'm not using it behind a Webhook I have an other bot running behind a webhook.

@fabston
Copy link
Owner

fabston commented Jun 20, 2021

Yea that's the issue with the Webhook setup. Well if threaded=False did the trick I guess you don't need the Webhook solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants