Telegram Bot - Connection Aborted

Viewed 498

Hello has anyone had this error when using pyTelegramBotAPI:

raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(10054, 'An existing connection was forced to be aborted by the remote host', None, 10054, None)).

This is the code I am using:

import telebot 
import time
import logging

Token = TOKEN
bot = telebot.TeleBot(Token) 

def send_signals(text):
    #sendMessage  
    chats = chatID
    try:         
       bot.send_message(chats, text)  
    except (ConnectionAbortedError, ConnectionResetError, ConnectionRefusedError, ConnectionError):
       time.sleep(1)
       bot.send_message(chats, text)

The bot has to send 3 messages, for example it sends a first message at 2:21 (it is not an absolute time), then another at 2:30 and when trying to send the last one sometimes I get this error. Or even from the first message it sends me the error.

Any idea how to solve it?

0 Answers
Related