Python aiohttp asyncio errors

  aiohttp, python, python-3.x, windows
from aiohttp_socks import SocksConnector, ProxyConnector, ProxyType
from aiohttp import ClientSession
async def parse_posts():
    connector = ProxyConnector.from_url('socks5://176.9.75.42:1080')
    async with ClientSession(connector=connector) as session:
        async with await session.get('https://google.com/') as resp:
            print(await resp.text())
import asyncio
loop = asyncio.get_event_loop()
loop.run_until_complete(parse_posts())
loop.close()

Hi I am getting an error with reading it. Can you help though. OS is Windows 10. Here is my traceback, though I do not understand what is going on and what is wrong with it.

Traceback (most recent call last):
  File "C:UsersAdministratorDesktoptest.py", line 26, in <module>
    loop.run_until_complete(parse_posts())
  File "C:UsersAdministratorAppDataLocalProgramsPythonPython39libasynciobase_events.py", line 642, in run_until_complete
    return future.result()
  File "C:UsersAdministratorDesktoptest.py", line 21, in parse_posts
    async with await session.get('https://google.com/') as resp:
  File "C:UsersAdministratorAppDataLocalProgramsPythonPython39libsite-packagesaiohttpclient.py", line 520, in _request
    conn = await self._connector.connect(
  File "C:UsersAdministratorAppDataLocalProgramsPythonPython39libsite-packagesaiohttpconnector.py", line 535, in connect
    proto = await self._create_connection(req, traces, timeout)
  File "C:UsersAdministratorAppDataLocalProgramsPythonPython39libsite-packagesaiohttpconnector.py", line 892, in _create_connection
    _, proto = await self._create_direct_connection(req, traces, timeout)
  File "C:UsersAdministratorAppDataLocalProgramsPythonPython39libsite-packagesaiohttpconnector.py", line 1020, in _create_direct_connection
    transp, proto = await self._wrap_create_connection(
  File "C:UsersAdministratorAppDataLocalProgramsPythonPython39libsite-packagesaiohttp_socksconnector.py", line 58, in _wrap_create_connection
    stream = await proxy.connect(
  File "C:UsersAdministratorAppDataLocalProgramsPythonPython39libsite-packagespython_socksasync_asyncioext_proxy.py", line 47, in connect
    await self._connect()
  File "C:UsersAdministratorAppDataLocalProgramsPythonPython39libsite-packagespython_socksasync_asyncioext_proxy.py", line 79, in _connect
    await self._negotiate()
  File "C:UsersAdministratorAppDataLocalProgramsPythonPython39libsite-packagespython_socksasync_asyncioext_proxy.py", line 126, in _negotiate
    await proto.negotiate()
  File "C:UsersAdministratorAppDataLocalProgramsPythonPython39libsite-packagespython_socks_proto_socks5_async.py", line 36, in negotiate
    await self._socks_connect()
  File "C:UsersAdministratorAppDataLocalProgramsPythonPython39libsite-packagespython_socks_proto_socks5_async.py", line 81, in _socks_connect
    res = ConnectResponse(await self._stream.read_exact(3))
  File "C:UsersAdministratorAppDataLocalProgramsPythonPython39libsite-packagespython_socksasync_asyncioext_stream.py", line 80, in read_exact
    return await self._reader.readexactly(n)
  File "C:UsersAdministratorAppDataLocalProgramsPythonPython39libasynciostreams.py", line 721, in readexactly
    raise exceptions.IncompleteReadError(incomplete, n)
asyncio.exceptions.IncompleteReadError: 2 bytes read on a total of 3 expected bytes

Source: Windows Questions

LEAVE A COMMENT