requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer')), Python

Question:

I made a telegram bot and deployed it on Render.
All works fine for like 3 hours then the bot gets down and throws this error:

`raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(104, 'Connection reset by peer'))`

Worth mentioning that the server keeps being Live despite the error, but the bot gets totally out of service.

And when re-deploying it, it works fine for another 3 hours and then bot dies but server keeps Live.

I tried adding this code:

time.sleep(0.45)
r = requests.get(get_url(name), headers=headers)
if r.status_code == 200:
soup = bs(r.content, features='html.parser')

But did not help that much.
Any solutions?

Asked By: TheAtef

||

Answers:

Turned out I just needed to use
bot.infinity_polling()
instead of bot.polling()

Answered By: TheAtef