Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can not connect to python.org:80 [No route to host] #22

Closed
lwis opened this issue Oct 24, 2016 · 3 comments
Closed

Can not connect to python.org:80 [No route to host] #22

lwis opened this issue Oct 24, 2016 · 3 comments

Comments

@lwis
Copy link

lwis commented Oct 24, 2016

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
Copy link

gwillem commented Oct 27, 2016

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
Copy link
Author

lwis commented Oct 27, 2016

@gwillem ah, looks like they've recognised it as an issue in any case. Thanks for the detailed response.

@saghul saghul closed this as completed Oct 31, 2016
@fannigurt
Copy link

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)]]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants