0

I tried this code to bypass shiny server timeout issue in free version. But it is not working.

inactivity <- "function idleTimer() {
var t = setTimeout(logout, 60000);
window.onmousemove = resetTimer; // catches mouse movements
window.onmousedown = resetTimer; // catches mouse movements
window.onclick = resetTimer;     // catches mouse clicks
window.onscroll = resetTimer;    // catches scrolling
window.onkeypress = resetTimer;  //catches keyboard actions

    function logout() {
      //close the window
    }

    function resetTimer() {
    clearTimeout(t);
    t = setTimeout(logout, 60000);  // time is in milliseconds (1000 is 1 second)
    }
    }
    idleTimer();"


ui <- fluidPage(
  tags$script(inactivity))

server <- function(session, input, output) {

  points <- eventReactive(input$recalc, {
    cbind(rnorm(40) * 2 + 13, rnorm(40) + 48)
  }, ignoreNULL = FALSE)
  })

shinyApp(ui, server)

I need to make a shiny app to be active for atleast 10 mins. This code is suppose to bypass the session timeout issue in free version. But it is getting timeout after 1 min. What has to be done?

qwww
  • 1,313
  • 4
  • 22
  • 48
  • have a look a this, you're missing the actual event as you have nothing in the `logout()` function call https://stackoverflow.com/questions/33839543/shiny-server-session-time-out-doesnt-work – Pork Chop Nov 27 '18 at 13:18
  • How is it possible to overlook [this](https://stackoverflow.com/questions/33839543/shiny-server-session-time-out-doesnt-work)? You are almost using the same headline. – ismirsehregal Nov 27 '18 at 18:44
  • @PorkChop I need the window not to be disconnected or closed.. – qwww Nov 28 '18 at 04:13
  • The function doesnt do the server timeout, server timeouts work on per session basis, if you do need a server restart then you have to envoke `systemctl restart shiny-server` call with some other process (assuming you on ubuntu). Have a look how to invoke system commands with R https://stat.ethz.ch/R-manual/R-devel/library/base/html/system.html – Pork Chop Nov 28 '18 at 08:26

0 Answers0