-
-
Notifications
You must be signed in to change notification settings - Fork 243
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
Add a SSE reconnection mechanism #1807
Conversation
The heartbeat callback is called in the alive message listener and doesn't need to be called again inside setKeepalive method. The intervalId is removed on clearKeepalive. Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
This implements a reconnection mechanism on SSE failure that attempts a reconnection after 10 seconds. Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Job #896: Bundle Size — 15.67MiB (~-0.01%).Metrics (1 change)
Total size by type (2 changes)
|
Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
This is critical and very sensitive code but it also seems like with those changes it received proper care and should therefore be tested properly, so I cannot do that right now, but will do!
|
I agree that this should be tested, I am already doing that in my production since Tuesday. Works fine until now. Together with #1808 I have noticed that, if I leave Safari on my iPad and come back, the SSE connection is lost, but however thanks thanks to this PR it is restored in a matter of seconds. |
The heartbeatCallback should be called when the SSE connection times out. Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll admit I didn't do the exhaustive testing I wanted, but I don't think we should postpone it any further either since it seems quite the improvement - and the code looks good 👍
Depends on #1807. Currently, SSE connection and sending commands fail silently, which makes the user think that everything is fine, but instead outdated values are displayed and commands are not sent. This implements user warnings for such cases, a large openHAB orange toast "Communication failure" with the option to reload is displayed at the bottom center: - as long as SSE connection is broken - when sending a command to an Item failed for 5 sec If the Item does not exist (error code 404), "<Itemname> not found" is displayed for 5 sec -- Signed-off-by: Florian Hotze <florianh_dev@icloud.com>
Currently, on SSE failure there is no reliable reconnection mechanism (browsers might try something), e.g. on network failure, and therefore SSE connection is lost forever once an error occurs. To reconnect, the user has to change/reload the page.
This implements a SSE reconnection mechanism, that attempts a SSE reconnection after SSE failure.
The time is increasing from 1 -> 2 -> 4 -> 8 -> 10.