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

[RFH] [DO NOT MERGE] aiohttp + wifi mesh networks results in request hangs #103297

Closed

Conversation

Noltari
Copy link
Contributor

@Noltari Noltari commented Nov 3, 2023

Some users with Home Assistant behind Wifi Mesh networks are experiencing timeouts with the Airzone Cloud integration.
This integration uses aiohttp to communicate with the Cloud API and triggers most of the requests in parallel.

The issue is that some users, both of them with the Home Assistant server behind a Wifi mesh network are experiencing connection hangs which results in timeouts.
One of these users solved it by connecting the Home Assistant server to its router, but unfortunately this isn't possible for all of them.
However, it seems that limiting the number of parallel connections to 4 solves the issue.
It would be great if someone could shed some light here on how to fix this for these users.
Maybe there's something in aiohttp that I did wrong in my integration lib or something that can be tweaked...
I'm hoping that maybe someone has come across this issue in the past with a different integration...

(BTW, I'm opening this as a PR to have context about the integration and the debugging, but if this is not acceptable please tell me and I will create an issue or a post in the community)

Proposed change

None.

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

  • This PR fixes or closes issue: fixes #
  • This PR is related to issue:
  • Link to documentation pull request:

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Black (black --fast homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
  • Untested files have been added to .coveragerc.

To help with the load of incoming pull requests:

Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>
@elupus
Copy link
Contributor

elupus commented Nov 3, 2023

Just change to creating a new session and limit number of allowed parallel requests in the lib?

@Noltari
Copy link
Contributor Author

Noltari commented Nov 3, 2023

Just change to creating a new session and limit number of allowed parallel requests in the lib?

Yes, but isn't it strange to do that just because some users are experiencing that kind of failure?
I mean, that's just a patch, but it shouldn't be needed if things were working correctly, right?
The thing is I want to fix the root cause, not workaround it :$

@elupus
Copy link
Contributor

elupus commented Nov 3, 2023

Ps. I meant async_create_clientsession.

But yes seems a bit strange, i didnt realize it was not a integration issue per say.

That said.. There is a point in avoiding massive number of parallel requests against cloud services anyway. They put a large burdon, with little gain.

Maybe we do want some per server limit in parallel requests. But setting a limit globally would be hard.

@Noltari
Copy link
Contributor Author

Noltari commented Nov 3, 2023

Ps. I meant async_create_clientsession.

I don't think this would be fixed with async_create_clientsession because I've tried running the aioairzone-cloud examples in those environments and those fail too.
In fact in order to get them working I had to limit the number of connections to 4:
Noltari/aioairzone-cloud@d521736

It's strange that I can use the same account on my Home Assistant setup and I have no issues at all...

@Noltari
Copy link
Contributor Author

Noltari commented Nov 3, 2023

After further testing I would say this is related to this aiohttp issue:
aio-libs/aiohttp#3698

Because I've tested creating a new ClientSession() for each API request and it fixes the issue...

@Noltari Noltari closed this Nov 3, 2023
@Noltari Noltari mentioned this pull request Nov 3, 2023
20 tasks
@Noltari Noltari deleted the airzone-cloud-max-connections branch November 3, 2023 17:29
@github-actions github-actions bot locked and limited conversation to collaborators Nov 4, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants