Can not connect to python.org:80 [No route to host]
lwis opened this issue · 3 comments
lwis commented
Running the aiohttp client example on the homepage using aiodns 1.1.1 results in;
aiohttp.errors.ClientOSError: [Errno 65] Cannot connect to host python.org:80 ssl:False [Can not connect to python.org:80 [No route to host]]
However, running with aiodns 1.0.1 works without fault.
gwillem commented
You probably have an IPv6 stack but no route. Try this:
tcpconnector = aiohttp.TCPConnector(family=socket.AF_INET)
async with aiohttp.ClientSession(connector=tcpconnector) as session:
[...]
The default was changed in aiohttp
in aio-libs/aiohttp#561
lwis commented
@gwillem ah, looks like they've recognised it as an issue in any case. Thanks for the detailed response.
fannigurt commented
import socket
import aiohttp
import asyncio
import async_timeout
async def fetch(session, url):
with async_timeout.timeout(10):
async with session.get(url) as response:
return await response.text()
async def main():
async with aiohttp.ClientSession(connector=aiohttp.TCPConnector(family=socket.AF_INET)) as session:
html = await fetch(session, 'http://python.org')
print(html)
if __name__ == '__main__':
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
and
aiohttp.client_exceptions.ClientConnectorError: [Errno 1] Cannot connect to host python.org:443 ssl:True [Can not connect to python.org:443 [[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:749)]]