Commit graph

61 commits

Author SHA1 Message Date
J. Nick Koston
dbb5645e63
Significantly reduce websocket api connection auth phase latency (#108564)
* Significantly reduce websocket api connection auth phase latancy

Since the auth phase has exclusive control over the websocket
until ActiveConnection is created, we can bypass the queue and
send messages right away. This reduces the latancy and reconnect
time since we do not have to wait for the background processing
of the queue to send the auth ok message.

* only start the writer queue after auth is successful
2024-01-21 22:33:31 -05:00
J. Nick Koston
b4b041d4bf
Small cleanups to the websocket api handler (#108274) 2024-01-18 08:39:49 +01:00
J. Nick Koston
60ab360fe7
Avoid bytes to string to bytes conversion in websocket api (#108139) 2024-01-16 21:37:34 +01:00
J. Nick Koston
5648dc6cd1
Reduce string copy needed to subscribe to entities (#102870) 2023-10-28 09:18:25 -05:00
Marc Mueller
a9ade1f84d
Use asyncio.timeout [core] (#98447) 2023-08-15 08:36:05 -05:00
J. Nick Koston
d242eaa375
Remove the ability to defer websocket message construction (#96734)
This was added in #71364 but all use cases of it were refactored
away so it can now be removed
2023-07-17 08:41:39 +02:00
J. Nick Koston
2aff138b92
Small improvements to websocket api performance (#95693) 2023-07-02 12:33:25 -05:00
J. Nick Koston
3f18f515e7
Improve websocket api coverage and typing (#94891) 2023-06-20 15:21:24 +01:00
J. Nick Koston
1206f2c1da
Fix memory leaks in websocket api (#94780)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2023-06-19 18:27:22 -05:00
J. Nick Koston
b993fe1c9d
Cache generation of the service descriptions (#93131) 2023-05-16 21:42:37 -05:00
J. Nick Koston
2848f8648d
Log last message when websocket reaches peak limit (#93038)
When we hit the absolute limit, we would log the last messages as
it was key to finding out the source. We now do the same when
we hit the peak limit
2023-05-14 12:22:19 -04:00
J. Nick Koston
8711735ec0
Improve websocket throughput and reduce latency (#92967) 2023-05-13 00:13:57 +09:00
Paulus Schoutsen
0ca6723378
Allow passing binary to the WS connection (#89882)
* Allow passing binary to the WS connection

* Expand test coverage

* Test non-existing handler

* Allow signaling end of stream using empty payloads

* Store handlers in a list

* Handle binary handlers raising exceptions
2023-03-22 08:36:36 -04:00
J. Nick Koston
a8e95684fa
Fix websocket back pressure bottleneck (#89905) 2023-03-20 21:51:39 -10:00
epenet
ba23816a0c
Inverse json import logic (#88099)
* Fix helpers and util

* Adjust components

* Move back errors

* Add report

* mypy

* mypy

* Assert deprecation messages

* Move test_json_loads_object

* Adjust tests

* Fix rebase

* Adjust pylint plugin

* Fix plugin

* Adjust references

* Adjust backup tests
2023-02-16 11:37:57 +01:00
J. Nick Koston
0f4b17755e
Improve logging and handling when websocket gets behind (#86854)
fixes undefined
2023-01-29 10:49:27 -10:00
Franck Nijhof
5102d1a5f3
Drop Python 3.9 support (#85456) 2023-01-22 20:40:33 +01:00
Franck Nijhof
8819634b61
String formatting and max line length - Part 6 (#84525) 2022-12-24 13:19:51 +01:00
Joakim Sørensen
0dfc0af08c
Add CLOSED as an expected type (#83180) 2022-12-03 10:19:16 -05:00
Paulus Schoutsen
2ef14d60f3
Update pending message error (#80763) 2022-10-21 22:47:25 -04:00
J. Nick Koston
f6a03625ba
Implement websocket message coalescing (#77238)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-08-24 22:50:48 -05:00
Franck Nijhof
c8f700c803
Clean up accessing dispatcher helpers via hass (#72014)
Clean up accessing ditpatcher helpers via hass
2022-05-17 18:41:36 +02:00
J. Nick Koston
d612b9e0b4
Reduce event loop overhead for listeners that already queue (#71364)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2022-05-05 23:09:10 -04:00
Marc Mueller
9b9b553521
Disable no-self-use [pylint] (#70641)
* Disable no-self-use

* Remove disable comments
2022-04-25 07:41:01 -07:00
J. Nick Koston
10d6247fee
Bump to aiohttp 3.8.0 (#58974) 2021-11-04 10:07:50 -05:00
Marc Mueller
a48ddcadd4
Use assignment expressions 31 (#58715) 2021-10-30 16:29:07 +02:00
Paulus Schoutsen
6d0da631bf
Handle prepare timeout in websocket API (#55989) 2021-10-08 22:12:06 -07:00
David Boslee
7f966613bd
Disconnect websockets after token is revoked (#57091)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2021-10-08 09:38:22 -07:00
Paulus Schoutsen
677abcd484
Allow confirming local push notifications (#54947)
* Allow confirming local push notifications

* Fix from Zac

* Add tests
2021-09-22 23:17:04 +02:00
Marc Mueller
48bada5a18
Update pylint to 2.11.1 (#56364) 2021-09-18 13:52:59 +02:00
Ruslan Sayfutdinov
42ff687c32
Add missing type hints to websocket_api (#50915) 2021-05-21 09:39:18 -07:00
J. Nick Koston
11a56df2cb
Serialize websocket messages before placing them in the queue (#49582) 2021-04-28 08:55:18 -07:00
Erik Montnemery
703c073e53
Improve websocket debug log 2021-03-19 13:30:16 +01:00
Marc Mueller
dcca29ef68
Update typing 14 (#48078) 2021-03-18 15:08:35 +01:00
J. Nick Koston
3c84c7ccf0
Fix memory leak in websocket_api (#42894)
* Fix memory leak in websocket_api

Each named logger lives forever

* tweak
2020-11-06 09:27:41 +01:00
SigmaPic
51f847c4b8
Catch unhandled exception in websocket_api (#42693)
Co-authored-by: springstan <46536646+springstan@users.noreply.github.com>
Co-authored-by: Paulus Schoutsen <balloob@gmail.com>
2020-11-03 10:35:45 +01:00
J. Nick Koston
35cfc80dd7
Log the remote ip address for incoming websocket connections when debug is on (#40581) 2020-09-26 09:32:50 +02:00
J. Nick Koston
f0f817c361
Serialize websocket event message once (#40453)
Since most of the json serialize work for the websocket was done
multiple times for the same message, we can avoid the overhead
of serializing the same message many times (once per websocket
client) with a cache.
2020-09-22 08:47:04 -05:00
Ville Skyttä
b4bac0f7a0
Exception chaining and wrapping improvements (#39320)
* Remove unnecessary exception re-wraps

* Preserve exception chains on re-raise

We slap "from cause" to almost all possible cases here. In some cases it
could conceivably be better to do "from None" if we really want to hide
the cause. However those should be in the minority, and "from cause"
should be an improvement over the corresponding raise without a "from"
in all cases anyway.

The only case where we raise from None here is in plex, where the
exception for an original invalid SSL cert is not the root cause for
failure to validate a newly fetched one.

Follow local convention on exception variable names if there is a
consistent one, otherwise `err` to match with majority of codebase.

* Fix mistaken re-wrap in homematicip_cloud/hap.py

Missed the difference between HmipConnectionError and
HmipcConnectionError.

* Do not hide original error on plex new cert validation error

Original is not the cause for the new one, but showing old in the
traceback is useful nevertheless.
2020-08-28 13:50:32 +02:00
J. Nick Koston
578d4a9b6a
Make the frontend available sooner (Part 1 of 2) (#36263)
* Part 1 of 2 (no breaking changes in part 1).

When integrations configured via the UI block startup or fail to start,
the webserver can remain offline which make it is impossible
to recover without manually changing files in
.storage since the UI is not available.

This change is the foundation that part 2 will build on
and enable a listener to start the webserver when the frontend
is finished loading.

Frontend Changes (home-assistant/frontend#6068)

* Address review comments

* bump timeout to 1800s, adjust comment

* bump timeout to 4h

* remove timeout failsafe

* and the test
2020-06-02 13:54:11 -05:00
Pascal Vizeli
ed014e3c96
Revert "Ensure frontend is available if integrations fail to start - Part 1 of 2 (#36093)" (#36251)
This reverts commit fbe7b4ddfa.
2020-05-29 10:18:39 +02:00
J. Nick Koston
fbe7b4ddfa
Ensure frontend is available if integrations fail to start - Part 1 of 2 (#36093)
Co-authored-by: Paulus Schoutsen <paulus@home-assistant.io>
2020-05-28 21:09:07 -07:00
Ville Skyttä
f8416484f8
More data entry flow and HTTP related type hints (#34430) 2020-05-26 09:28:22 -05:00
Paulus Schoutsen
d93c09327a
Report unserializable data in websocket (#34072)
* Report unserializable data in websocket

* Fix tests

* log types too
2020-04-13 23:46:41 -07:00
Paulus Schoutsen
bea354b82a
Allow WS queue to temporarily peak (#34175)
* Allow WS queue to temporarily peak

* Remove unused code
2020-04-13 18:50:36 -07:00
springstan
6de8072e8a Move imports to top for websocket_api (#29556)
* Move imports to top for websocket_api

* Move back an import because of circular dependency, add annotations
2019-12-08 12:19:15 +01:00
Ville Skyttä
381d423fec Upgrade mypy to 0.740 (#27913)
* Upgrade mypy to 0.740

http://mypy-lang.blogspot.com/2019/10/mypy-0740-released.html

* Type hint additions

* Type fixes

* Remove no longer needed type ignores and casts

* Disable untyped definition checks in bunch of files
2019-10-19 11:35:57 -07:00
Paulus Schoutsen
c9e26b6fd0
Improve speed websocket sends messages (#27295)
* Improve speed websocket sends messages

* return -> continue
2019-10-07 20:08:07 -07:00
Ville Skyttä
f259ff17d5
Type hint additions (#26831)
* Type hint additions

* Remove optional from sidebar_icon comment

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* Remove optional from sidebar_title comment

Co-Authored-By: Franck Nijhof <frenck@frenck.nl>

* Fix issues after rebase and mypy 0.730
2019-09-29 20:07:49 +03:00
Franck Nijhof
b1118cb8ff Removes unnecessary else/elif blocks (#26884) 2019-09-24 13:53:03 -07:00