shinyproxy
shinyproxy copied to clipboard
Persist a session and reconnect after navigating away
Been trying to do a bit of research on connecting to an already running session and coming up a bit stumped.
Currently when a user wants to use an app, they spin up a container and then connect to it. Data loads etc. etc. can happen. If a user is disconnected (but still has the page loaded), there is the ability to reconnect to the websocket and not lose everything.
If you navigate away from the loaded app (e.g. closing the tab) and then go back to it, you "start from 0" and lose all the data loaded plus where you were in the app. Of course you could cache the data + bookmark the state and try and reload this, but it adds a lot of additional stuff to code into the apps.
A user would surely want to open an app, navigate away and then come back to it and be in the exact same state (as long as it hasn't timed out). Particularly as we now have "Stop App" and "Restart App" which allows the user to go to 0.
It's the same as having multiple instances. A user would probably expect an instances session to persist and be reconnected to if they closed the tab, and then went back to it through the switch instance modal.
Is this a limitation of Shiny, where once leaving the webpage, it is impossible to return to that session, is it something that could be a feature of ShinyProxy, or is there something that can be done in Shiny itself?
Is this a limitation of Shiny, where once leaving the webpage, it is impossible to return to that session
As far as I know, this is indeed a limitation of Shiny. Every time you load a Shiny web-app, it starts a websocket connection with a unique sessionId. This is the session
variable in the R code. An application typically attaches some information to this session, which is ultimately attached to this sessionId. The idea is that multiple users can re-use the same Shiny/R process without affecting other users.
In the ShinyProxy world such a R or Shiny process is dedicated to a single user, because we run a Docker container with a R process for each user. Therefore, this principle of having multiple users in a single Shiny app does not apply. Therefore you could maybe store the state separately from the session
. Every time a new session comes in (i.e. a page load), you treat this is as the same user/session and continue with the existing data. This is just an idea, I don't know whether this is (easily) possible with Shiny.
I don't think this is something we can influence from the ShinyProxy side, since this really is behavior from the R/Shiny system.
I will investigate this a bit more myself to see if anything can be done, thanks for the response.