-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
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
Fix myq increasing number of network connections #22432
Fix myq increasing number of network connections #22432
Conversation
Can you elaborate what changes in your session fixed the leak socket issue? If so, maybe we should change |
So this is what I have found out so far. This is experience and testing with aiohttp for 2 components that were having issues on certain deployments of HassIO. Harmony component (through library aioharmony) is using websockets from aiohttp. People were having regular disconnects and then re-connections failing. Sometimes also with errors like "Network unreachable" etc... The whole conversation related to aioharmony is here: https://community.home-assistant.io/t/harmony-hub-problems-after-update/98460 Next issue with myq. Somewhat similar but they would just see the number of connections keep on increasing even although it's supposed to keep the connection open and using pooling (all managed through aiohttp). What I currently do now know however is what if it is only enable_cleanup_closed=True and family is not set. I know with the issue on websockets I had to set it to resolve that issue. |
I believe It seems happened in particular website, which didn't handle the SSL connection close gracefully. |
You can create a new websession with same connector pool with the helper. I would prefere that one because it need less resource and home assistant is care that this session will be closed: https://github.com/home-assistant/home-assistant/blob/dev/homeassistant/helpers/aiohttp_client.py#L49 |
It's not about creating new sessions. It's about aiohttp "leaking" connections. Same connection pool is being used but and idea is same connection is used all the time. Yet on certain platforms they were seeing a constant increase in number of connections. |
Just checking
|
Not sure what needs to be done further to get this approved. I see a number of new checks sitting there though. |
5f86e12
to
1647a02
Compare
Codecov Report
@@ Coverage Diff @@
## dev #22432 +/- ##
=======================================
Coverage 93.83% 93.83%
=======================================
Files 448 448
Lines 36574 36574
=======================================
Hits 34321 34321
Misses 2253 2253
Continue to review full report at Codecov.
|
I think it has been confirmed that |
Changed it back to use aiohttp helper client from HA and updated aiohttp helper client to include this option. |
Fix for network issues
websession is created in pymyq instead. Added call on stop event to close web session.
Enable automatic cleanup of closed sockets in aiohttp client helper.
bb8ab51
to
d660210
Compare
Per aiohttp document
However add this option will apply to all clients, would you mind take a look into it? |
I think that it's fine. |
Description:
Updated pymyq version to 1.2.0. The aiohttp client session is now setup within the pymyq library instead with tested socket options to prevent continuous increase in sockets on certain platforms.
Related issue (if applicable): fixes #9193
Checklist:
tox
. Your PR cannot be merged unless tests passIf the code communicates with devices, web services, or third-party tools:
requirements_all.txt
by runningscript/gen_requirements_all.py
.