Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Complains on network during polling updates #283

Open
kancom opened this issue Jul 21, 2023 · 1 comment
Open

Complains on network during polling updates #283

kancom opened this issue Jul 21, 2023 · 1 comment
Labels
question Further information is requested

Comments

@kancom
Copy link

kancom commented Jul 21, 2023

I have two bots running on the same server (in containers).
Bot are using dialogs 1.9.0
One of them is almost idle, but like every couple of minutes keeps it dumps the error.
The other one doesn't have such problem at all. Both container has absolutely the same build script..

Maybe you could direct where to dig...?

the error:

 ERROR:aiogram.dispatcher.dispatcher:Cause exception while getting updates.
 Traceback (most recent call last):
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/bot/api.py", line 139, in make_request
     async with session.post(url, data=req, **kwargs) as response:
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiohttp/client.py", line 1141, in __aenter__
     self._resp = await self._coro
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiohttp/client.py", line 560, in _request
     await resp.start(conn)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 899, in start
     message, payload = await protocol.read()  # type: ignore[union-attr]
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiohttp/streams.py", line 616, in read
     await self._waiter
 aiohttp.client_exceptions.ClientOSError: [Errno 104] Connection reset by peer

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 381, in start_polling
     updates = await self.bot.get_updates(
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/bot/bot.py", line 110, in get_updates
     result = await self.request(api.Methods.GET_UPDATES, payload)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/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 "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/bot/api.py", line 142, in make_request
     raise exceptions.NetworkError(f"aiohttp client throws an error: {e.__class__.__name__}: {e}")
 aiogram.utils.exceptions.NetworkError: Aiohttp client throws an error: ClientOSError: [Errno 104] Connection reset by peer
 ERROR:asyncio:Task exception was never retrieved
 future: <Task finished name='Task-2961' coro=<Dispatcher._process_polling_updates() done, defined at /root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py:407> exception=N
etworkError('Aiohttp client throws an error: ClientOSError: [Errno 104] Connection reset by peer')>
 Traceback (most recent call last):
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/bot/api.py", line 139, in make_request
     async with session.post(url, data=req, **kwargs) as response:
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiohttp/client.py", line 1141, in __aenter__
     self._resp = await self._coro
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiohttp/client.py", line 560, in _request
     await resp.start(conn)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 899, in start
     message, payload = await protocol.read()  # type: ignore[union-attr]
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiohttp/streams.py", line 616, in read
     await self._waiter
 aiohttp.client_exceptions.ClientOSError: [Errno 104] Connection reset by peer

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 415, in _process_polling_updates
     for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 235, in process_updates
     return await asyncio.gather(*tasks)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/dispatcher/handler.py", line 117, in notify
     response = await handler_obj.handler(*args, **partial_data)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 256, in process_update
     return await self.message_handlers.notify(update.message)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/dispatcher/handler.py", line 117, in notify
     response = await handler_obj.handler(*args, **partial_data)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram_dialog/dialog.py", line 170, in _message_handler
     await self.show(dialog_manager)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram_dialog/dialog.py", line 147, in show
     message = await manager.show(new_message)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram_dialog/manager/manager.py", line 217, in show
     res = await self._registry.message_manager.show_message(
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram_dialog/message_manager.py", line 48, in show_message
     await self.remove_kbd(bot, old_message)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram_dialog/message_manager.py", line 86, in remove_kbd
     await bot.edit_message_reply_markup(
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/bot/bot.py", line 3252, in edit_message_reply_markup
     result = await self.request(api.Methods.EDIT_MESSAGE_REPLY_MARKUP, payload)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/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 "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/bot/api.py", line 142, in make_request
     raise exceptions.NetworkError(f"aiohttp client throws an error: {e.__class__.__name__}: {e}")
 aiogram.utils.exceptions.NetworkError: Aiohttp client throws an error: ClientOSError: [Errno 104] Connection reset by peer

maybe this is also related (appears also like every 5 minutes):

 ERROR:asyncio:Task exception was never retrieved
 future: <Task finished name='Task-3939' coro=<Dispatcher._process_polling_updates() done, defined at /root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py:407> exception=TypeError("'NoneType' object is not iterable")>
 Traceback (most recent call last):
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 415, in _process_polling_updates
     for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)):
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 235, in process_updates
     return await asyncio.gather(*tasks)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/dispatcher/handler.py", line 117, in notify
     response = await handler_obj.handler(*args, **partial_data)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/dispatcher/dispatcher.py", line 256, in process_update
     return await self.message_handlers.notify(update.message)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram/dispatcher/handler.py", line 117, in notify
     response = await handler_obj.handler(*args, **partial_data)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram_dialog/dialog.py", line 170, in _message_handler
     await self.show(dialog_manager)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram_dialog/dialog.py", line 137, in show
     new_message = await window.render(self, manager)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram_dialog/window.py", line 77, in render
     current_data = await self.load_data(dialog, manager)
   File "/root/.local/share/virtualenvs/app-4PlAip0Q/lib/python3.9/site-packages/aiogram_dialog/window.py", line 62, in load_data
     data.update(await self.getter(**manager.data))
 TypeError: 'NoneType' object is not iterable

@Tishka17
Copy link
Owner

It is difficult to say something based on this logs.

Network errors are really strange if they appear only on one bot. One of possible reasons may be using same asyncio object from multiple threads, but it's just guessing.

The second tracebacks looks like a problem with window getter. Did you implement it correctly? Looks like you have forgottent return

@Tishka17 Tishka17 added the question Further information is requested label Aug 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants