D
D
Dimas42018-09-01 09:57:19
Python
Dimas4, 2018-09-01 09:57:19

AioHttp error Cannot connect to host *site here*:443 ssl:None [Connect call failed ('*his ip*', 443)]?

There are many urls. You need to make inquiries. Function for requests:

async def get_html_2(session, url):
    try:
        async with session.get(url) as response:
            return await response.text()
    except Exception as e:
        print(url, e)

async def html_get(url):
    async with aiohttp.ClientSession() as session:
        html = await get_html_2(session, url)
        return html

Call:
loop = asyncio.get_event_loop()
result.append(asyncio.ensure_future(html_get(BASE_URL.format(urllib.parse.quote(j[0]))))) # это проходит в цикле, поэтому 
# формируется урлов много. сам цикл здесь пропустил
result = loop.run_until_complete(asyncio.gather(*result))

As a result, almost all requests throw the error
Cannot connect to host *here site*:443 ssl:None [Connect call failed ('*his ip*', 443)]
How can I fix this?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alex, 2021-04-12
@Alex_woland

When using WINDOWS with python>=3.8, aiohttp<=3.7.4 with proxy, the error "... Cannot connect to host *website here*:443 ssl:default ..." can be solved like this:

import sys
if sys.version_info[0] == 3 and sys.version_info[1] >= 8 and sys.platform.startswith('win'):
    policy = asyncio.WindowsSelectorEventLoopPolicy()
    asyncio.set_event_loop_policy(policy)

https://github.com/aio-libs/aiohttp/issues/4536

S
slovnet, 2020-12-02
@slovnet

see what requests are accepted by the server you are accessing. Here is the doc https://docs.aiohttp.org/en/stable/client_advanced...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question