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

ProactorEventLoop cannot open connection to ::1 #71687

Closed
sebastienbourdeauducq mannequin opened this issue Jul 12, 2016 · 11 comments
Closed

ProactorEventLoop cannot open connection to ::1 #71687

sebastienbourdeauducq mannequin opened this issue Jul 12, 2016 · 11 comments

Comments

@sebastienbourdeauducq
Copy link
Mannequin

sebastienbourdeauducq mannequin commented Jul 12, 2016

BPO 27500
Nosy @gvanrossum, @gpshead, @vstinner, @1st1, @miss-islington, @alexbers
PRs
  • bpo-27500: Fix sttaic ver of getaddrinfo to resolve IPv6 addresses #7993
  • [3.7] bpo-27500: Fix static version of getaddrinfo to resolve IPv6 (GH-7993) #8000
  • [3.6] bpo-27500: Fix static version of getaddrinfo to resolve IPv6 (GH-7993) #8001
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2019-01-15.12:13:50.175>
    created_at = <Date 2016-07-12.17:55:35.017>
    labels = ['expert-asyncio']
    title = 'ProactorEventLoop cannot open connection to ::1'
    updated_at = <Date 2019-01-15.12:24:02.730>
    user = 'https://bugs.python.org/sebastienbourdeauducq'

    bugs.python.org fields:

    activity = <Date 2019-01-15.12:24:02.730>
    actor = 'sebastien.bourdeauducq'
    assignee = 'none'
    closed = True
    closed_date = <Date 2019-01-15.12:13:50.175>
    closer = 'vstinner'
    components = ['asyncio']
    creation = <Date 2016-07-12.17:55:35.017>
    creator = 'sebastien.bourdeauducq'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 27500
    keywords = ['patch']
    message_count = 11.0
    messages = ['270258', '270263', '288712', '317997', '320660', '320675', '320676', '320693', '320694', '320695', '333692']
    nosy_count = 7.0
    nosy_names = ['gvanrossum', 'gregory.p.smith', 'vstinner', 'yselivanov', 'sebastien.bourdeauducq', 'miss-islington', 'bay']
    pr_nums = ['7993', '8000', '8001']
    priority = 'high'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue27500'
    versions = ['Python 3.5']

    @sebastienbourdeauducq
    Copy link
    Mannequin Author

    sebastienbourdeauducq mannequin commented Jul 12, 2016

    The following code fails with "OSError: [WinError 10022] An invalid argument was supplied".

    import asyncio
    loop = asyncio.ProactorEventLoop()
    asyncio.set_event_loop(loop)
    loop.run_until_complete(asyncio.open_connection("::1", 4242))

    This is a regression in 3.5.2. 3.5.1 does not have this bug. Connecting to 127.0.0.1 does not cause the problem.

    @sebastienbourdeauducq
    Copy link
    Mannequin Author

    sebastienbourdeauducq mannequin commented Jul 12, 2016

    The first offending commit is this one:
    03df54d

    more specifically "return af, type, proto, '', (host, port)". For IPv6, it should be "(host, port, flow info, scope id)" instead of just "(host, port)".

    @sebastienbourdeauducq
    Copy link
    Mannequin Author

    sebastienbourdeauducq mannequin commented Feb 28, 2017

    This is still a problem with Python 3.5.3 and 3.6.0.

    @sebastienbourdeauducq
    Copy link
    Mannequin Author

    sebastienbourdeauducq mannequin commented May 29, 2018

    Any chance someone could look into this bug?

    @alexbers
    Copy link
    Mannequin

    alexbers mannequin commented Jun 28, 2018

    The bug is reproducible on Python 3.7. The connect call always fails when I
    try to use connect to any IPv6 address with ProactorEventLoop.

    The bug can be bypassed by adding "%0" to the IPv6 address. This will cause
    to trigger this if construction:

    if '%' in host:

    As mentioned by Sebastian, it happen because the _ipaddr_info function returns
    only the host and the port for IPv6: return af, type, proto, '', (host, port)

    return af, type, proto, '', (host, port)

    This (host, port) tuple used in ConnectEx call, but it expect 4-element tuple
    to connect IPv6:

    else if (PyArg_ParseTuple(obj,

    Instead it tries to connect, using IPv4 and fails.

    The bug can be fixed by doing the following:
    if af == socket.AF_INET6:
    return af, type, proto, '', (host, port, 0, 0)
    else:
    return af, type, proto, '', (host, port)

    instead of
    return af, type, proto, '', (host, port)

    in

    return af, type, proto, '', (host, port)

    @gvanrossum
    Copy link
    Member

    Somebody please submit a PR so this can be fixed in 3.7.1 and the fix can
    be backported to 3.6.7.

    @1st1
    Copy link
    Member

    1st1 commented Jun 28, 2018

    Somebody please submit a PR so this can be fixed in 3.7.1 and the fix can
    be backported to 3.6.7.

    Somehow I overlooked this one when I was sifting the issues we needed to fix in 3.7. I've opened a PR.

    @1st1
    Copy link
    Member

    1st1 commented Jun 29, 2018

    New changeset d904c23 by Yury Selivanov in branch 'master':
    bpo-27500: Fix static version of getaddrinfo to resolve IPv6 (GH-7993)
    d904c23

    @miss-islington
    Copy link
    Contributor

    New changeset 3ed4414 by Miss Islington (bot) in branch '3.7':
    bpo-27500: Fix static version of getaddrinfo to resolve IPv6 (GH-7993)
    3ed4414

    @miss-islington
    Copy link
    Contributor

    New changeset c00144c by Miss Islington (bot) in branch '3.6':
    bpo-27500: Fix static version of getaddrinfo to resolve IPv6 (GH-7993)
    c00144c

    @sebastienbourdeauducq
    Copy link
    Mannequin Author

    sebastienbourdeauducq mannequin commented Jan 15, 2019

    Thank you!

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Projects
    None yet
    Development

    No branches or pull requests

    4 participants