Updating Shiny Server Config to change timeout error
Fixed it using this SO answer User session is getting interrupted after approx. 45 seconds
I was putting the http_keepalive_timeout
function in the wrong place. Please see below for the correct shiny-server.conf
update:
# Instruct Shiny Server to run applications as the user "shiny"
run_as shiny;
http_keepalive_timeout 180;
# Define a server that listens on port 3838
server {
listen 3838;
# Define a location at the base URL
location / {
# Host the directory of Shiny Apps stored in this directory
site_dir /srv/shiny-server;
# Log all Shiny output to files in this directory
log_dir /var/log/shiny-server;
# When a user visits the base URL rather than a particular application,
# an index of the applications available in this directory will be shown.
directory_index on;
}
}
Shiny server session time out doesn't work
You can configure your idle
time within the shiny
app like so using some JS, here the app will timeout after 5 seconds.
library(shiny)
library(leaflet)
inactivity <- "function idleTimer() {
var t = setTimeout(logout, 5000);
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() {
window.close(); //close the window
}
function resetTimer() {
clearTimeout(t);
t = setTimeout(logout, 5000); // time is in milliseconds (1000 is 1 second)
}
}
idleTimer();"
ui <- fluidPage(
tags$script(inactivity),
leafletOutput("mymap")
)
server <- shinyServer(function(input,output,session){
points <- eventReactive(input$recalc, {
cbind(rnorm(40) * 2 + 13, rnorm(40) + 48)
}, ignoreNULL = FALSE)
output$mymap <- renderLeaflet({
leaflet() %>%
addProviderTiles(providers$Stamen.TonerLite,options = providerTileOptions(noWrap = TRUE)) %>%
addMarkers(data = points())
})
})
runApp(list(ui = ui, server = server))
User session is getting interrupted after approx. 45 seconds
Well, after searching and trying out different options I was able to find the answers to my questions.
- The user session was getting interrupted around approximately 45 seconds every single time because the
http_keepalive_timeout
parameter was not defined in theserver configuration
and thedefault value
forhttp_keepalive_timeout
parameter is45 seconds
. To prevent the session from getting reaped before the report generation, I added the
http_keepalive_timeout
parameter to theshiny-server.conf
at thetop level
and set it's value to120 seconds
as shown below.http_keepalive_timeout 120;
You can set the http_keepalive_timeout
value as per your wish. I set it to 120
as my application is taking around 100-110 seconds
to generate the report.
Reference: shiny server configuration
Related Topics
.Htaccess Redirect Index.PHP to /
Bind Outgoing Traffic to Eth0 Instead of Eth0:1
Would It Be Possible to Read Out Physical Keyboard Strokes in Node.Js
When Is Posix Thread Cancellation Not Immediate
Cargo Plugin Throws Cargoexception When Deploying on Glassfish - Deployment Has Failed: Null
How to Avoid Grub Errors After Running Apt-Get Upgrade - Ubuntu
How to Find Files Containing a String Using Egrep
Posix_Fadvise(Willneed) Makes Io Slower
Driver Ch341 Usb Adapter Serial Port or Qserialport Not Works in Linux
How to Pass Local Variable to Remote Using Ssh and Bash Script
Programmatically Disable Hardware Prefetching on Amd Systems
Set Environment Variable in Gdb from Output of Command
Running R in Batch Mode on Linux: Output Issues
Linux - Modify File Modify/Access/Change Time
How to Log from a Non-Root Debian Linux Daemon