Skip to content

Implement “Happy Eyeballs” algorithim (RFC 8305) in socket.create_connection() #88810

Open

Description

@origin400-p
BPO 44644

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 = None
created_at = <Date 2021-07-15.12:05:20.908>
labels = ['library', '3.9', 'performance']
title = 'Implement \xe2\x80\x9cHappy Eyeballs\xe2\x80\x9d algorithim (RFC 8503) in socket.create_connection()'
updated_at = <Date 2021-07-15.12:05:20.908>
user = 'https://bugs.python.org/origin400-p'

bugs.python.org fields:

activity = <Date 2021-07-15.12:05:20.908>
actor = 'origin400-p'
assignee = 'none'
closed = False
closed_date = None
closer = None
components = ['Library (Lib)']
creation = <Date 2021-07-15.12:05:20.908>
creator = 'origin400-p'
dependencies = []
files = []
hgrepos = []
issue_num = 44644
keywords = []
message_count = 1.0
messages = ['397542']
nosy_count = 1.0
nosy_names = ['origin400-p']
pr_nums = []
priority = 'normal'
resolution = None
stage = None
status = 'open'
superseder = None
type = 'performance'
url = 'https://bugs.python.org/issue44644'
versions = ['Python 3.9']

Activity

  1. origin400-p commented on Jul 15, 2021

    origin400-pmannequin
    MannequinAuthor

    While support for the so-called “Happy Eyeballs” algorithim described in RFC 8305 was implemented for asyncio in Issue bpo-33530, socket's create_connection function remains left without it causing suboptimal performance in broken dual-stack environments.

  2. added
    3.9 (EOL)
    stdlib
    performance
    on Jul 15, 2021
  3. transferred this issue fromon Apr 10, 2022
  4. added
    type-feature
    3.12
    and removed
    3.9 (EOL)
    on Aug 26, 2022
  5. added
    3.13
    and removed
    3.12
    on May 26, 2023
  6. changed the title [-]Implement “Happy Eyeballs” algorithim (RFC 8503) in socket.create_connection()[/-] [+]Implement “Happy Eyeballs” algorithim (RFC 8305) in socket.create_connection()[/+] on May 26, 2023
  7. gpshead commented on May 26, 2023

    @gpshead
    Member

    socket.create_connection() does indeed need this feature. In addition to our existing asyncio implementation's behavior we could also look at what Golang has done, they implemented the original rfc-6555 quite a while back and are tracking 8305 in golang/go#23841. (even only implementing rfc-6555's variant would be a big improvement)

  8. gpshead commented on May 26, 2023

    @gpshead
    Member

    It'd also be interesting if we could avoid maintaining two implementations of this in the stdlib so long as the cost to do so is not even more complicated to maintain. (ex: Would the ironic thing of socket.create_connection running its own singular asyncio event loop just for the duration of this task feasible or a Bad Idea™️ ?)

  9. graingert commented on Dec 12, 2024

    @graingert
    Contributor

    @gpshead this would then break users that use create_connection inside an existing asyncio event loop

  10. graingert commented on Dec 12, 2024

    @graingert
    Contributor

    @sethmlarson has a sync implementation of happy eyeballs, it might be an idea to land that in cpython

  11. intempus-kasperd commented on Feb 11, 2026

    @intempus-kasperd

    @graingert Is your last comment implying that there already exists an implementation which could simply be copied into socket.py?

    If there is no implementation yet I might have a go at implementing one. Would a patch to update create_connection in socket.py be accepted if the code is of good quality?

    A few questions:

    • Would there have to be a setting to switch RFC 8305 behavior on/off, or can it be on always?
    • Would an implementation which still calls getaddrinfo and only implements the remaining parts of RFC 8305 be welcome?
    • Can other of the advanced features be left out in order to more quickly finalize an implementation of the most needed parts of the RFC?
    • Which API should be used for waiting for connections? I know epoll is preferred in some environments, but other alternatives may be more portable.
    • Does an implementation need to include any additional workarounds for legacy sites such as github, or is acceptable that you still can't reach such sites with create_connection from an IPv6-only network?
  12. added
    topic-socket
    on Jul 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.13performancestdlibtopic-sockettype-feature

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions