Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to prevent a shiny app from being grayed out?

Tags:

r

heroku

shiny

we have a shiny app hosted in Heroku. After 55 secs of user inactivity, the app will be grayed out. This is applicable for Chrome and Safari. Edge is working fine. Heroku have a default timeout for that, and it looks like it cannot be modified using the R buildpack (https://github.com/virtualstaticvoid/heroku-shiny-app).



    function ping() {
        if (!window.Shiny.shinyapp.isConnected()) {
            window.Shiny.shinyapp.reconnect();
        }
    }
    setInterval(ping, 2000);

We embedded below JS code to reconnect using the WebSocket, but the session data is lost. Is there anything else we can try?

Here is more info about our app: R 3.4.4 Shiny 1.1.0

like image 974
stackoverflow2019 Avatar asked Dec 08 '22 12:12

stackoverflow2019


1 Answers

After 55 secs of user inactivity, the app will be grayed out.

I had a similar problem, but the context was different (this was due to proxy settings and I didn't use Heroku) so I don't know whether the solution I used is an option for you (I post it here because my reply is too long for a comment).

I simply included these lines:

  autoInvalidate <- reactiveTimer(10000)
  observe({
    autoInvalidate()
    cat(".")
  })

In this way a dot is printed in the console by every passage of 10 secs and my app didn't gray out anymore (though this is not really a "user activity").

like image 94
Stéphane Laurent Avatar answered Dec 31 '22 23:12

Stéphane Laurent