Cause exception while getting updates python

Прерывное подключение бота к серверу

Бот написан с использованием библиотеки aiogram. Проблема заключается в том, что после запуска бота, через некоторое количество часов, pycharm начинает выкидывать ошибки. Точно не могу понять, это как-то я облажался с с лупом или все же сам сервер, где запущен бот, переодически отключается, что и выдает такие логи.

WARNING:aiogram:Updates were skipped successfully. INFO:aiogram.dispatcher.dispatcher:Start polling. ERROR:aiogram.dispatcher.dispatcher:Cause exception while getting updates. Traceback (most recent call last): File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\bot\api.py", line 139, in make_request async with session.post(url, data=req, **kwargs) as response: File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\client.py", line 1141, in __aenter__ self._resp = await self._coro File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\client.py", line 560, in _request await resp.start(conn) File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\client_reqrep.py", line 899, in start message, payload = await protocol.read() # type: ignore[union-attr] File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\streams.py", line 616, in read await self._waiter aiohttp.client_exceptions.ClientOSError: [WinError 64] Указанное сетевое имя более недоступно During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 381, in start_polling updates = await self.bot.get_updates( File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\bot\bot.py", line 110, in get_updates result = await self.request(api.Methods.GET_UPDATES, payload) File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\bot\base.py", line 236, in request return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files, File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\bot\api.py", line 142, in make_request raise exceptions.NetworkError(f"aiohttp client throws an error: : ") aiogram.utils.exceptions.NetworkError: Aiohttp client throws an error: ClientOSError: [WinError 64] Указанное сетевое имя более недоступно ERROR:aiogram.dispatcher.dispatcher:Cause exception while getting updates. Traceback (most recent call last): File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\bot\api.py", line 139, in make_request async with session.post(url, data=req, **kwargs) as response: File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\client.py", line 1141, in __aenter__ self._resp = await self._coro File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\client.py", line 560, in _request await resp.start(conn) File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\client_reqrep.py", line 899, in start message, payload = await protocol.read() # type: ignore[union-attr] File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiohttp\streams.py", line 616, in read await self._waiter aiohttp.client_exceptions.ClientOSError: [WinError 64] Указанное сетевое имя более недоступно During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\dispatcher\dispatcher.py", line 381, in start_polling updates = await self.bot.get_updates( File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\bot\bot.py", line 110, in get_updates result = await self.request(api.Methods.GET_UPDATES, payload) File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\bot\base.py", line 236, in request return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files, File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\site-packages\aiogram\bot\api.py", line 142, in make_request raise exceptions.NetworkError(f"aiohttp client throws an error: : ") aiogram.utils.exceptions.NetworkError: Aiohttp client throws an error: ClientOSError: [WinError 64] Указанное сетевое имя более недоступно ERROR:asyncio:Exception in callback _ProactorBasePipeTransport._call_connection_lost(None) handle: Traceback (most recent call last): File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\asyncio\events.py", line 80, in _run self._context.run(self._callback, *self._args) File "C:\Users\name\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 162, in _call_connection_lost self._sock.shutdown(socket.SHUT_RDWR) ConnectionResetError: [WinError 10054] Удаленный хост принудительно разорвал существующее подключение 

Источник

Читайте также:  Php define application path

При запуски Телеграм бота ошибка — ERROR:aiogram.dispatcher.dispatcher:Cause exception while getting updates

Здорова всем. Решил научится разбираться в bot_telegram выбрал библиотеку (aiogram) для создания бота. При использовании Python 3.7 вроде как работало но пришлось перейти на Python 3.8 одна часть функционала бота не работала на Python 3.7. Anaconda (version 1.7.2)
Python (version 3.8.5) Вывод с консоля.

ERROR:aiogram.dispatcher.dispatcher:Cause exception while getting updates. Traceback (most recent call last): File "/home/dus/anaconda3/lib/python3.8/site-packages/aiogram/dispatcher/dispatcher.py", line 359, in start_polling updates = await self.bot.get_updates(limit=limit, offset=offset, timeout=timeout) File "/home/dus/anaconda3/lib/python3.8/contextlib.py", line 120, in __exit__ next(self.gen) File "/home/dus/anaconda3/lib/python3.8/site-packages/aiogram/bot/base.py", line 162, in request_timeout self._ctx_timeout.reset(token) ValueError: at 0x7f82298dee80> was created in a different Context ERROR:aiogram.dispatcher.dispatcher:Cause exception while getting updates. Traceback (most recent call last): WARNING:aiogram:Goodbye! WARNING:aiogram.dispatcher.dispatcher:Polling is stopped. 
from config import API_TOKEN import logging from datetime import datetime from aiogram import Bot, Dispatcher, executor, types from aiogram.dispatcher.filters.state import State, StatesGroup import keybords as kb from time import sleep from aiogram.dispatcher import FSMContext from aiogram.contrib.fsm_storage.memory import MemoryStorage import nest_asyncio logging.basicConfig(level=logging.INFO) bot = Bot(token = API_TOKEN) dp = Dispatcher(bot, storage=MemoryStorage()) nest_asyncio.apply() class Form(StatesGroup): day = State() hour = State() minutes = State() @dp.message_handler(commands=['alarm']) async def alarm(message: types.Message): await message.answer("Plsm,input day for alarm") await Form.day.set() @dp.message_handler(state=Form.day) async def answerDay(message: types.Message, state: FSMContext): answer_day = message.text await state.update_data(answer_day1 = answer_day ) await message.answer("Plsm,input hour for alarm") await Form.hour.set() @dp.message_handler(state=Form.hour) async def answerHour(message: types.Message, state: FSMContext): answer_hour = message.text await state.update_data(answer_hour1 = answer_hour ) await message.answer("Plsm,input minutes for alarm") await Form.minutes.set() @dp.message_handler(state=Form.minutes) async def answerMinutes(message: types.Message, state: FSMContext): data = await state.get_data() answer_day1 = data.get("answer_day1") answer_hour1 = data.get("answer_hour1") answer_minutes = message.text datatime.now() while True : time_now = datetime.now() if str(time_now.hour) == answer_hour1 and str(time_now.minute) == answer_minutes and str(time_now.day) == answer_day1: await bot.send_message (message.chat.id, 'time to wake up') break sleep (1) # await state.finish() @dp.message_handler(commands=['start']) async def start(message: types.Message): await message.answer('This bot help you set the alarm and use API for choice random music.' ,reply_markup=kb.greet_kb) @dp.message_handler(commands=['time']) async def time_now (message: types.Message): time = datetime.now() b = time.strftime('Time now is ' + '%H:%M:%S' + '\n' '%A,%d' + '\n' '%B, %Y') await message.answer(b) @dp.message_handler(commands=['help']) async def help (message: types.Message): await message.answer( text = ''' This telegram bot was created as an alarm clock that can search for random music and use it to awakening more easily. /time - show actual time and date now. /alarm - help you set alarm. The format used is 24 hours. ''' ) if __name__ == '__main__': executor.start_polling(dp, skip_updates=True) 

Источник

Читайте также:  Java print all methods

TimeoutError aiogram bot

i have a bot which parses some links given by user.
When clients want to parse realy huge amount of links, bot parses them, creates csv file from those links, sends it to user(user can download and view this file) and then raise TimeoutError

Cause exception while getting updates. Traceback (most recent call last): File "/Users/alex26/miniforge3/envs/rq/lib/python3.8/site-packages/aiogram/dispatcher/dispatcher.py", line 381, in start_polling updates = await self.bot.get_updates( File "/Users/alex26/miniforge3/envs/rq/lib/python3.8/site-packages/aiogram/bot/bot.py", line 110, in get_updates result = await self.request(api.Methods.GET_UPDATES, payload) File "/Users/alex26/miniforge3/envs/rq/lib/python3.8/site-packages/aiogram/bot/base.py", line 231, in request return await api.make_request(await self.get_session(), self.server, self.__token, method, data, files, File "/Users/alex26/miniforge3/envs/rq/lib/python3.8/site-packages/aiogram/bot/api.py", line 139, in make_request async with session.post(url, data=req, **kwargs) as response: File "/Users/alex26/miniforge3/envs/rq/lib/python3.8/site-packages/aiohttp/client.py", line 1138, in __aenter__ self._resp = await self._coro File "/Users/alex26/miniforge3/envs/rq/lib/python3.8/site-packages/aiohttp/client.py", line 559, in _request await resp.start(conn) File "/Users/alex26/miniforge3/envs/rq/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 913, in start self._continue = None File "/Users/alex26/miniforge3/envs/rq/lib/python3.8/site-packages/aiohttp/helpers.py", line 721, in __exit__ raise asyncio.TimeoutError from None asyncio.exceptions.TimeoutError 
 bot = Bot(token=API_TOKEN) dp = Dispatcher(bot) def parse_1000_links(): #it takes about 10 mins and therefore that's the same like sleep(600) sleep(600) @dp.message_handler() async def msg_handler(message: types.Message): if msg == 'parse 1000 links': res = parse_1000_links() create_csv_from_res(res) file_open_obj = open('data.csv', 'rb') await bot.send_document(message.from_user.id, file_open_obj) . if __name__ == '__main__': executor.start_polling(dp, skip_updates=True) 

User can even get from bot this final file, but after sending this file to user, bot raises this error. That’s strange. If user get message, it means that everything is fine(That’s my opinion)
How to fix my issue?
Thanks

Источник

Оцените статью