-
Notifications
You must be signed in to change notification settings - Fork 52
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
ui-template nodes not receiving messages after network disconnection/recovery. #747
Comments
Also see possibly related issues #620 and #444 and forum discussion https://discourse.nodered.org/t/ui-template-fully-kiosk-browser-update-problem-dashboard-2/87003 |
I had hoped that this would be fixed by the comms enhancements in 1.8.0 but it seems not. I have updated the description to reflect the slightly changed symptoms with 1.8.0 |
Note that just switching pages and back again is enough restore normal operation. |
I'll give this a go in the coming days |
Any further forward with this issue pls, it's proving to be a pain! |
I apologize, I lost track of this issue. Will try an make some headway this week! |
Follow up: Haven't lost track of this issue but I'll have to postpone the investigation to next week |
After a lot of poking/prodding, wild goose chases and theories, I may have found the culprit for this specific scenario The UITemplate's anonymous component is unmounted and re-mounted on socket reconnect. The unmounted method calls
As to why anonymous components are getting unmounted/remounted on socket disconnect is still unclear to me and would need more time to investigate while the socket.off() seems to be a good practice, and a common one across the repo. I'll try and pick up where I left off in a couple of days time. |
Fighting anonymous components reactivity on socket disconnect was a dead end, as there are a lot of factors would have side effects on the socket - anon component relationship. Embracing side effects is the way to go. Not 100% sure if the dataTracker was intended to be bound to the parent component, but binding it to the anonymous component seems to have no side effects plus the added benefit of re connecting on component lifecycle refresh caused by the socket disconnect. Creating a PR to address the problem |
Using DB v1.14.0 this is still not working for me when viewing on a android phone with the dashboard installed as a PWA app. db2.mp4Example flow -
Note: I have tried deleting the app from my phone, and re-installing it, and same result. |
Thanks Paul - have re-opened the issue and will investigate - maybe @cstns can take another look? |
Is this happening anywhere else other than mobile/pwa? |
I have managed to replicate the issue on Android, but not otherwise. It does not always fail, I am trying to work out what the trigger is. |
Running in Android with current main from github, using remote debugging, if I break the network connection to the server then I see
Where Baseline.vue has
After that all is gone to pot. |
Ooh - good find @colinl - that's odd that the alert isn't mounted though 🤔 |
@cstns - I've only noticed it on mobile/PWA. @colinl - I always get the reconnecting alert, so it is reconnecting (my screen recorder didn't capture that as it's set to record the app and not the screen). If I refresh the page, the data again flows, but yes, if I let it sleep, it almost always fails again. |
I can make it fail with that error when installed as an app in Edge on a PC with the flow below. It is running the prototype of my classic gauge widget when it was implemented in a ui-template. It does not fail when not running as an app.
In fact I am not convinced that this is the same problem that @Paul-Reed is seeing as the symptom is different, but I think that if there is a repeatable error then then it is worth fixing that issue, even if one is not convinced that it is the same problem.
|
I think it must be something to do with the template contents as I have other templates that do not give the problem. Or perhaps it is some sort of race condition so it varies unpredictably. |
FF Customer hitting this problem - @cstns can you prioritise sooner rather than later please? |
Yes, It managed to slip through the cracks. |
Tried my best to replicate the issue but with no success and I used both @colinl & @Paul-Reed's flows. My personal phone is a Pixel 7 Pro running android 14. For some reason I'm not able to connect in debug mode to it and get access to chrome's dev tools so i don't really know if there are any errors in the console. In order to install the pwa app on my device I needed valid tls certificates so what I ended up doing is spinning up a docker container with a node-red and dashboard combo and using ngrok to tunnel the app towards a public address with valid tls certs. When developing the initial fix, I managed to fake a network disconnect locally by removing the docker container with node-red from the virtual network and reconnecting it shortly after, succesfully and predictably reproducing the bug. No matter how long I left my phone in a sleeping state, connecting or disconnecting the phones wifi / mobile network using, disconnecting/connecting the docker container to the vlan and any combo of these procedures did not reproduce the bug. In order to get access to the mobile console and fidgeting with my device for too long, I installed Android Studio locally and emulated my phone (Pixel 7 Pro running android 14). With the pwa installed and access to the console I did notice something odd in that once the app disconnects, the xhr poll frequency decreases from once every three seconds to once every 30 seconds giving the impression that the the connection is not re-established for 30 or so seconds. Nonetheless, I was not able to replicate the described results in the emulator either. With Android Studio installed I could emulate any version of android, I haven't tried 13 yet. |
I was worried that my setup was somehow interfeering but after some more fidgeting I was able to replicate colinl's error predictably, which prevent's ws reconnect on network reconnect.
Tricky to replicate consistently as it only occurs when you first open the app or changing pages. It does not occur however if the page was refreshed.. I'll see what's mishbehaving with the alert component first thing tomorrow. Still not able to replicate it on pc |
I have deleted my earlier post from a few hours ago, it seems I was not paying attention when I posted it. |
You were right though, I found a way to replicate the bug consistently on desktop as well. There's something strange happening to the alert component reference on route changes between different layouts in the Baseline.vue component. It was a bit tricky to figure out but I got there |
The conclusion is that WebSocket connectivity was lost because the entire Vue application failed silently due to lifecycle inconsistencies between the parent Baseline.vue and child UiNotification.vue components. I've tested all mentioned scenarios successfully but would appreciate if anyone with a bit of free time on their hand could confirm on their end that the fix addressed the problem as well. |
Building as I type. |
Looks good to me. I had hoped this might be related to #1251, but apparently not. |
Current Behavior
If the network connection between the browser and the server is broken for even a few seconds and then restored, ui-template nodes reset to their initial state and stop receiving messages.
The same symptom can be seen on Android if the page is put in the background for a while, or even left in the foreground with an extended period of non-interaction with the user. I suspect Android is putting the page to sleep which effectively means that it is disconnected from the network.
Expected Behavior
The dashboard should recover after re-connection.
Steps To Reproduce
2024-04-25 Edited below to reflect slightly different symptoms with dashboard 1.8.0
With the dashboard browser on a different machine to the server, import the flow below (which is slightly extended version of the default ui-template) and deploy.
Refresh the dashboard browser. Initially the counter shows a count of 0.
With the developer console open on the dashboard page, click the Inject button in the editor.
The received message is shown in the developer console and the counter is incremented by 5 as expected.
Disconnect the network from the machine showing the dashboard for a few seconds. A connection error is shown in the developer console and the Connection Lost popup is shown.
Reconnect the network. The connection restored popup appears.
Click the Inject button. No message is shown in the console.
Click the Increment button on the dashboard and the counter does increment.
Refreshing the browser restores a working system.
Environment
Have you provided an initial effort estimate for this issue?
I am not a FlowFuse employee
The text was updated successfully, but these errors were encountered: