W
W
wi1ex2017-03-02 05:17:34
Python
wi1ex, 2017-03-02 05:17:34

Telegram bot stops responding, is it getupdates, code or vps?

I wrote a bot in python3.6 , in the tasks of which it is worth responding to commands and in parallel checking whether there is a mention in the tasks to notify a particular user. The bot is launched on the hosting (Ubuntu 16.04 LTS) with the command
python3.6 /root/1.3/bot.py >/dev/null 2>/root/1.3/logs/errors.txt &
and in the processes I observe 5 active bot.py I
use getUpdates , I check automatic notifications like this:

threading.Thread(target=bot.polling).start()
while True:
  autonotif()
  time.sleep(60)

When launched, the bot works, but after 15-20 hours, if you write to it, it may not answer, and only 4 bot.py remains in the processes . Moreover, notifications continue to work, and the bot no longer receives updates of requests. If you end the processes and restart the bot, an encoding error like this appears:
Traceback (most recent call last):
...
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 2: ordinal not in range(128)

Exception in thread Thread-1:
Traceback (most recent call last):
...
UnicodeEncodeError: 'ascii' codec can't encode characters in position 35-41: ordinal not in range(128)

The error disappears only if you restart the server and start it again, then you can again notice 5 active bot processes and after a while the problem repeats. Before I started using multithreading for notifications, this problem was not observed. But at the same time, it is she who continues to work if the bot falls asleep and one process stops. There was a version that the encoding error appears precisely because of the inability on the Telegram side to receive a new updated request from my side. But what causes falling asleep is unknown.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
nllm, 2017-03-02
@nllm

It looks like it crashes because of the encoding. A request comes from the user, where the first name and last name are in Cyrillic.
At 99%, the problem is in the code, and not on third-party services (hosting, telegram)

A
Andrey Grinevich, 2017-03-10
@Derfirm

I would advise you to install some sentry free or other monitoring service. Yes, and move away from threads, "debug threads" - that's another adventure.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question