aiohttp documents HTTP proxy support through its request options. A SOCKS endpoint needs an implementation that speaks SOCKS. Changing a proxy URL's port to 1080 does not supply that implementation.

Inside an async function, use the connector supplied by the maintained aiohttp-socks project:

import aiohttp
from aiohttp_socks import ProxyConnector

connector = ProxyConnector.from_url('socks5://203.0.113.10:1080')
async with aiohttp.ClientSession(connector=connector) as session:
    async with session.get('https://example.com/') as response:
        body = await response.read()

This assumes the connector package is already available and compatible with the aiohttp version in the application. The endpoint is illustrative; the SOCKS5 proxy list offers public candidates for the connector URL. Configure timeout and response-size policy for the actual workload.

Old answers refer to several different packages and connector names: aiosocks, aiosocksy, and aiohttp-socks are not interchangeable import paths. Read the requirements and example for the package actually used. Combining one project's class with another project's arguments can fail before any proxy connection is attempted.

Keep the connector and session lifetime together, and check hostname-resolution behavior where it matters. Passing a SOCKS URL to an unrelated HTTP proxy option is not a substitute for the connector's documented route.

Ũhoro ũhĩtĩte