-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Support Happy Eyeballs from Python 3.8 #4451
Comments
Unfortunately, this is not enough and has no effect because Lines 969 to 1025 in 8c25b44
An alternative is implementing the Happy Eyeballs algorithm in the aiohttp library reusing I would create a method similar to Then I'd call There would be a couple of problems though:
|
fixes #97146 This problem keeps coming up over and over again and its likely aio-libs/aiohttp#4451 will not be solved anytime soon
ESPHome has the same/similar issue esphome/aioesphomeapi#233 We need a happy eyeballs implementation that supports passing in a list of resolved addresses that works for python 3.8 for aiohttp so we can solve #4451 (comment) Ideally we build a lib for that which could be used for both esphome and aiohttp so we don't have to reinvent the wheel as I'm sure other places need it as well. The 3.8 support will be a bit of a pain though since we need use a conditional import with https://pypi.org/project/async-stagger/ as If I find the time to build something for esphome, I'll do it as a new library with a compatible license in case there is a chance we can reuse it here. |
I've got three projects I'm working on that need this so I think my holiday project is going to be to build a permissive licensed library that they can all use |
for hinfo in hosts:
host = hinfo["host"]
port = hinfo["port"]
# Strip trailing dots, certificates contain FQDN without dots.
# See https://github.com/aio-libs/aiohttp/issues/3636
server_hostname = (
(req.server_hostname or hinfo["hostname"]).rstrip(".")
if sslcontext
else None
)
try:
transp, proto = await self._wrap_create_connection(
self._factory,
host,
port,
timeout=timeout,
ssl=sslcontext,
family=hinfo["family"],
proto=hinfo["proto"],
flags=hinfo["flags"],
server_hostname=server_hostname,
local_addr=self._local_addr,
req=req,
client_error=client_error,
) If we swap out Unfortunately most of Worse it looks like we have to resolve local addrs as well since technically that works now |
I sliced up the stdlib create_connection into a new library https://github.com/bdraco/aiohappyeyeballs to allow connecting with Happy Eyeballs when you already have a list of addrinfo and not a DNS name. |
Is there any interest in adding something in asyncio upstream to support it as well later on? |
I think thats a good idea to be able to land it there at some point as the code is almost 100% extracted from cpython except the utils and added typing+tests. The current asyncio |
aio-libs/aiohttp#4451 is now available so this is no longer needed
aio-libs/aiohttp#4451 is now available so this is no longer needed
Starting from Python 3.8 asyncio supports https://tools.ietf.org/html/rfc6555
It allows working better in dual-host configurations.
It would be nice to support it by aiohttp if the feature is available by Python version.
Perhaps passing
happy_eyeballs_delay
andinterleave
toloop.create_connection()
is enough.A volunteer is welcome!
P.S.
Ooops, parameters are even not documented by asyncio docs, need to fix it.
The text was updated successfully, but these errors were encountered: