-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
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
Use client session for cloud with AF_INET connector #102759
Conversation
Hey there @home-assistant/cloud, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Since this is a general issue with aiohttp, I'd imagine we are going to apply this integration by integration. Could we maybe make this change globally somehow? 🤔 |
It was already implemented in |
This is basically what it does? As in, it is a property when getting the session. They will still share the same pools (when the family matches). |
I think Stefan meant that we should just add this to the global create session. If IPv6 is broken, we should never fallback to it for any integration? |
Yes. This would also allow to remove it globally once aiohttp gets fixed. This is assuming that all issues are related to the same aiohttp problem. |
I'm unsure about august, but it might be the same as with cloud. unrelated to coreFor HACS I also see the same issue as with cloud from time-to-timeFor Cloudflare, that only supports A records, so using v6 there does not make sense. So there might be several reasons why forcing v4 is wanted. |
I think that also depends on the service. So maybe in the future we will have IPv6 on our cloud, and then we can use it, but now that is not supported and need dual stack or ipv4 only networks. btw, I don't get why it need a new file and not directly create this as single-line change |
I did the new file for consistency but moved it to inline with 8edde8b |
If only A records are resolved, aiohttp (or rather the underlying socket implementation) will automatically choose the correct socket. For this no explicit socket configuration is required.
Wait, our servers do support IPv6 don't they? E.g. From what I understand, this is exactly the problem: Client has troubles connecting via IPv6 to the server. This is typically caused by bad IPv6 configuration on the users network (or routing issue on ISP side). Usually, when such issues happen in IPv4 world, people fix them (as in ISP fixes the routes, user reboots/reconfigures/replaces the router etc). In IPv6 world, rather than debug the problem, the solution is usually to just disable IPv6 altogether (since there is the IPv4 fallback makes things then just work). Just disabling IPv6 on the client as a whole is not an ideal solution, as this affects any IPv6 connection (other connections might still work e.g. local IPv6 connections etc.). To combat this problem RFC6555 aka Happy Eyeballs has been standardized. It essentially standardizes that even if a IP client has a valid (global) IPv6 address to speak to the server, and that connection fails for unknown reason, it falls back (quickly) to IPv4, so essentially does what this PR does automatically. And as #98003 mentions, aiohttp doesn't support Happy Eyeballs yet (aio-libs/aiohttp#4451). So this PR is a work around for missing Happy Eyeballs support in aiohttp. But yeah, in the end it depends also on the service: If a service only supports IPv4 on the other end, this work around is not needed. But it also wouldn't hurt actually, since the other endpoint only supports IPv4, the explicit ask for IMHO, this really calls for a (Sidenote: If aiohttp doesn't get fixed, an people would like to use Home Assistant in a IPv6 only environment, this would allow to disable the work around on a global level too). Maybe such a global session is a bit out of scope for this PR (since it would touch multiple integrations). I can do this in a separate PR, if preferred. |
The integration only supports that, the service supports both. Which then gives problems with dual-stack setups or setups with broken v6. Closing this PR for now as what it set out to do currently seems impossible to get accepted. |
What do you mean the integration only supports that (as in what does that refers to)?
No please don't! I am sorry if I made the impression I am against this change! This change fixes an issue, I am very much agreeing. I just try to clarify what is exactly being addressed here, and try to make a suggestion on the implementation. As I said, I am happy to do this in a follow up PR! |
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 aio-libs/aiohttp#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 with aiohttp. |
aiohttp 3.10.0 has happyeyeballs support so hopefully if this was still an issue, it will be solved in 2024.8.0 |
Proposed change
Disable IPv6 for the client session used by the cloud integration, similar to #98003, which was made possible by #102702.
Type of change
Additional information
Checklist
black --fast homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: