user@instance-1:~$ sudo systemctl status telegrambot.service
● telegrambot.service - Telegram Bot
Loaded: loaded (/etc/systemd/system/telegrambot.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sat 2020-05-16 07:43:49 UTC; 42min ago
Process: 40184 ExecStart=/home/user/telegrambot/venv/bin/python /home/user/telegrambot/bot.py (code=exited, status=1/FAILURE)
Main PID: 40184 (code=exited, status=1/FAILURE)
May 16 07:43:49 instance-1 python[40184]: result = _get_req_session().request(method, request_url, params=params, files=files,
May 16 07:43:49 instance-1 python[40184]: File "/home/user/telegrambot/venv/lib/python3.8/site-packages/requests/sessions.py", line 530, in request
May 16 07:43:49 instance-1 python[40184]: resp = self.send(prep, **send_kwargs)
May 16 07:43:49 instance-1 python[40184]: File "/home/user/telegrambot/venv/lib/python3.8/site-packages/requests/sessions.py", line 643, in send
May 16 07:43:49 instance-1 python[40184]: r = adapter.send(request, **kwargs)
May 16 07:43:49 instance-1 python[40184]: File "/home/user/telegrambot/venv/lib/python3.8/site-packages/requests/adapters.py", line 498, in send
May 16 07:43:49 instance-1 python[40184]: raise ConnectionError(err, request=request)
May 16 07:43:49 instance-1 python[40184]: requests.exceptions.ConnectionError: ('Connection aborted.', OSError("(104, 'ECONNRESET')"))
May 16 07:43:49 instance-1 systemd[1]: telegrambot.service: Main process exited, code=exited, status=1/FAILURE
May 16 07:43:49 instance-1 systemd[1]: telegrambot.service: Failed with result 'exit-code'.
Can someone help me with this issue? Server running on Ubuntu at Google Cloud Platform
This works for me
while True:
try:
bot.polling(none_stop=True)
except Exception as e:
logger.error(e) # or just print(e) if you don't have logger,
# or import traceback; traceback.print_exc() for print full info
time.sleep(15)