SSL:APPLICATION_DATA_AFTER_CLOSE_NOTIFY 错误

MrL*_*atg 5 python tor python-asyncio aiohttp

我使用 tor 的 http 代理(使用 aiohttp_socks)通过 aiohttp 发送多个请求

完成一些请求后,我收到以下错误:

Traceback (most recent call last):
  File "main.py", line 171, in <module>
    loop.run_until_complete(future)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "main.py", line 95, in get_market_pages
    async with session.get(active_link, headers=headers) as response:
  File "/home/mrlalatg/.local/lib/python3.8/site-packages/aiohttp/client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "/home/mrlalatg/.local/lib/python3.8/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/home/mrlalatg/.local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 847, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/home/mrlalatg/.local/lib/python3.8/site-packages/aiohttp/streams.py", line 591, in read
    await self._waiter
aiohttp.client_exceptions.ClientOSError: [Errno 1] [SSL: APPLICATION_DATA_AFTER_CLOSE_NOTIFY] application data after close notify (_ssl.c:2745)
Run Code Online (Sandbox Code Playgroud)

除了有关类似错误的 git 讨论之外,我找不到有关此错误的任何信息 - github

在那里我找到了一个解决方法(链接),我可以修改它来忽略此错误,但它不起作用,错误仍然存​​在。

解决方法的修改版本:

Traceback (most recent call last):
  File "main.py", line 171, in <module>
    loop.run_until_complete(future)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "main.py", line 95, in get_market_pages
    async with session.get(active_link, headers=headers) as response:
  File "/home/mrlalatg/.local/lib/python3.8/site-packages/aiohttp/client.py", line 1012, in __aenter__
    self._resp = await self._coro
  File "/home/mrlalatg/.local/lib/python3.8/site-packages/aiohttp/client.py", line 504, in _request
    await resp.start(conn)
  File "/home/mrlalatg/.local/lib/python3.8/site-packages/aiohttp/client_reqrep.py", line 847, in start
    message, payload = await self._protocol.read()  # type: ignore  # noqa
  File "/home/mrlalatg/.local/lib/python3.8/site-packages/aiohttp/streams.py", line 591, in read
    await self._waiter
aiohttp.client_exceptions.ClientOSError: [Errno 1] [SSL: APPLICATION_DATA_AFTER_CLOSE_NOTIFY] application data after close notify (_ssl.c:2745)
Run Code Online (Sandbox Code Playgroud)

小智 1

不确定这是否有帮助,但我犯了一个简单的错误:关闭 aiohttp.ClientSession,同时在其下方缩进更多代码。查看会话是否在代码中的某个位置关闭。