@arseniylebedev

Почему aiohttp web сервер перестает отвечать на запросы?

aiohttp принимает обновления от telegram. В какой-то момент просто повис без ошибок в логе (На сообщения в telegram перестал отвечать, новые запросы от telegram в логе тоже не появлялись), когда стал закрывать через CTRL+C в логе появилась ошибка.

aiohttp==3.9.1
сервер запущен на win10pro
антивирус windows не отключен, может быть из-за него?

лог

2023-12-06 02:59:41,236 [INFO] Запускаю обработчик тасков
2023-12-06 02:59:41,252 [INFO] Запускаю обработчик эвентов
2023-12-06 02:59:41,315 [INFO] Запускаю удаление старых платежей
2023-12-06 02:59:41,377 [INFO] Запускаю бота с токеном: <токен бота>
2023-12-06 02:59:41,408 [INFO] Бот будет запущен через webhook
2023-12-06 02:59:56,474 [INFO] 91.108.6.64 [06/Dec/2023:02:59:56 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:00:11,668 [INFO] 91.108.6.64 [06/Dec/2023:03:00:11 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:00:24,340 [INFO] Проверка что текущая страница загружена
2023-12-06 03:00:24,348 [INFO] Состояние страницы complete
2023-12-06 03:00:24,453 [INFO] Starting chrome full page screenshot workaround ...
2023-12-06 03:00:24,470 [INFO] Total: (1903, 1417), Viewport: (1903,1080)
2023-12-06 03:00:24,471 [INFO] Appending rectangle (0,0,1903,1080)
2023-12-06 03:00:24,471 [INFO] Appending rectangle (0,1080,1903,1417)
2023-12-06 03:00:24,767 [INFO] Adding to stitched image with offset (0, 0)
2023-12-06 03:00:24,802 [INFO] Scrolled To (0,1080)
2023-12-06 03:00:25,213 [INFO] Adding to stitched image with offset (0, 337)
2023-12-06 03:00:25,360 [INFO] Finishing chrome full page screenshot workaround...
2023-12-06 03:08:12,994 [INFO] 91.108.6.64 [06/Dec/2023:03:08:12 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:08:17,746 [INFO] 91.108.6.64 [06/Dec/2023:03:08:17 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:08:20,238 [INFO] 91.108.6.64 [06/Dec/2023:03:08:20 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:29:19,693 [INFO] 91.108.6.64 [06/Dec/2023:03:29:19 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:29:25,836 [INFO] 91.108.6.64 [06/Dec/2023:03:29:25 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:29:41,696 [INFO] 91.108.6.64 [06/Dec/2023:03:29:41 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:29:46,557 [INFO] 91.108.6.64 [06/Dec/2023:03:29:46 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:34:48,511 [INFO] 91.108.6.64 [06/Dec/2023:03:34:48 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:34:55,372 [INFO] 91.108.6.64 [06/Dec/2023:03:34:55 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:35:02,004 [INFO] 91.108.6.64 [06/Dec/2023:03:35:01 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:43:44,669 [INFO] 91.108.6.64 [06/Dec/2023:03:43:44 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:43:47,685 [INFO] 91.108.6.64 [06/Dec/2023:03:43:47 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:43:51,343 [INFO] 91.108.6.64 [06/Dec/2023:03:43:51 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:43:54,250 [INFO] 91.108.6.64 [06/Dec/2023:03:43:54 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:43:57,002 [INFO] 91.108.6.64 [06/Dec/2023:03:43:56 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:44:00,128 [INFO] 91.108.6.64 [06/Dec/2023:03:44:00 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:44:04,801 [INFO] 91.108.6.64 [06/Dec/2023:03:44:04 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:44:08,599 [INFO] 91.108.6.64 [06/Dec/2023:03:44:08 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:44:09,444 [INFO] 91.108.6.64 [06/Dec/2023:03:44:09 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 03:44:23,840 [INFO] 91.108.6.64 [06/Dec/2023:03:44:23 +0300] "POST /<токен бота>/ HTTP/1.1" 200 150 "-" "-"
2023-12-06 05:09:58,898 [INFO] 83.97.73.87 [06/Dec/2023:05:09:58 +0300] "GET / HTTP/1.1" 404 192 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
2023-12-06 05:13:27,976 [INFO] 83.97.73.87 [06/Dec/2023:05:13:27 +0300] "POST /Autodiscover/Autodiscover.xml HTTP/1.1" 404 192 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
2023-12-06 05:17:21,523 [INFO] 83.97.73.87 [06/Dec/2023:05:17:21 +0300] "POST /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php HTTP/1.1" 404 192 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
2023-12-06 05:21:23,350 [INFO] 44.204.194.146 [06/Dec/2023:05:21:23 +0300] "GET / HTTP/1.1" 404 173 "-" "Mozilla/5.0 (Windows NT 6.2;en-US) AppleWebKit/537.32.36 (KHTML, live Gecko) Chrome/60.0.3014.59 Safari/537.32"
2023-12-06 05:23:03,763 [INFO] 83.97.73.87 [06/Dec/2023:05:23:03 +0300] "GET /vendor/phpunit/phpunit/src/Util/PHP/eval-stdin.php HTTP/1.1" 404 192 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
2023-12-06 05:28:38,857 [INFO] 83.97.73.87 [06/Dec/2023:05:28:38 +0300] "GET /?XDEBUG_SESSION_START=phpstorm HTTP/1.1" 404 192 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
2023-12-06 05:33:09,672 [INFO] 83.97.73.87 [06/Dec/2023:05:33:09 +0300] "GET /console/ HTTP/1.1" 405 223 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
2023-12-06 05:36:41,105 [INFO] 83.97.73.87 [06/Dec/2023:05:36:41 +0300] "GET /_ignition/execute-solution HTTP/1.1" 404 192 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
2023-12-06 05:41:50,912 [INFO] 83.97.73.87 [06/Dec/2023:05:41:50 +0300] "GET / HTTP/1.1" 404 192 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
2023-12-06 05:46:22,257 [INFO] 83.97.73.87 [06/Dec/2023:05:46:22 +0300] "GET / HTTP/1.1" 404 192 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
2023-12-06 05:51:43,430 [INFO] 83.97.73.87 [06/Dec/2023:05:51:43 +0300] "GET /actuator/gateway/routes HTTP/1.1" 404 192 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36"
2023-12-06 16:36:44,584 [ERROR] Task exception was never retrieved
future: .accept_coro() done, defined at C:\Users\emerald\AppData\Local\Programs\Python\Python311\Lib\asyncio\windows_events.py:597> exception=OSError(22, 'Указанное сетевое имя более недоступно', None, 64, None)>
Traceback (most recent call last):
File "C:\Users\emerald\AppData\Local\Programs\Python\Python311\Lib\asyncio\windows_events.py", line 600, in accept_coro
await future
File "C:\Users\emerald\AppData\Local\Programs\Python\Python311\Lib\asyncio\windows_events.py", line 846, in _poll
value = callback(transferred, key, ov)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\emerald\AppData\Local\Programs\Python\Python311\Lib\asyncio\windows_events.py", line 589, in finish_accept
ov.getresult()
OSError: [WinError 64] Указанное сетевое имя более недоступно
2023-12-06 16:36:44,788 [ERROR] Accept failed on a socket
socket:
Traceback (most recent call last):
File "C:\Users\emerald\AppData\Local\Programs\Python\Python311\Lib\asyncio\proactor_events.py", line 843, in loop
conn, addr = f.result()
^^^^^^^^^^
OSError: [WinError 64] Указанное сетевое имя более недоступно
2023-12-06 16:37:29,006 [INFO] Ожидаю пока таски завершат свою работу
2023-12-06 16:37:29,038 [INFO] Завершил поток обработки тасков


код
import ssl

import telebot
from aiohttp import web

from bot_contacts.config import load_config

config = load_config()


def run_updates_server(bot: telebot.TeleBot):
    app = web.Application()

    async def handle(request):
        if request.match_info.get('token') == bot.token:
            request_body_dict = await request.json()
            update = telebot.types.Update.de_json(request_body_dict)
            bot.process_new_updates([update])
            return web.Response()
        else:
            return web.Response(status=403)

    app.router.add_post('/{token}/', handle)

    context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
    context.load_cert_chain(config["WEBHOOK_SERVER_SSL_CERT"], config["WEBHOOK_SERVER_SSL_PRIV"])

    web.run_app(
        app,
        host="0.0.0.0",
        port=8443,
        ssl_context=context,
    )
  • Вопрос задан
  • 158 просмотров
Пригласить эксперта
Ответы на вопрос 1
@Everything_is_bad
По логам больше похоже на сетевые проблемы, а так, винда не лучшая ОС для aiohttp
Ответ написан
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы