Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I prevent my Shiny App from disconnecting in a open-source shiny-server?

I'm running a R shiny application on an open source shiny-server, using Ubuntu and NGINX. However, my app keeps getting the message "Disconnected from the Server" for some reason and I can't seem to get it to work. The shiny app runs perfectly fine on my local.

I've tried the javascript workaround via the following suggestion in Shiny server session time out doesn't work, but it still doesn't seem to work.

Also tried to set app_idle_timeout and app_init_timeout to a longer duration, but to no avail.

This is my nginx config file:

server {
    listen 80;
    listen [::]:80;
    listen 443 ssl;

    server_name some_ip_address;

    location / {
         proxy_pass http://localhost:3838/;
         proxy_redirect http://localhost:3838/ $scheme://$host/;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection $connection_upgrade;
         proxy_read_timeout 20d;
    }

}

Was wondering if I editing shiny server or nginx config file to make this work? But I understand that it is only possible to extend the timeout in the pro version but I'm guessing there must be some workaround possible.

like image 351
ZPeh Avatar asked Jan 29 '19 08:01

ZPeh


People also ask

Why does my Shiny app keep disconnecting from server?

The "Disconnected from Server" error is a generic message that means that the R session has shut down for some reason. This could happen for a multitude of reasons, ranging from missing objects, to data that takes too long to load, to the use of forbidden packages, to hitting the application timeout settings.

Can you run Shiny app locally?

You might be eager to deploy your Shiny app to a remote server. But the simplest way to run a Shiny app is to run it locally. You only need the shiny R package installed, and you can run the app in your browser. In this post you'll see a few ways of how to organize your files to be served locally.


1 Answers

You can disable application idle timeouts in Shiny Server (open source or Pro) by setting app_idle_timeout to 0 in your Shiny Server config file.

For example,

location / {
    app_idle_timeout 0;
}

https://docs.rstudio.com/shiny-server/#application-timeouts

app_idle_timeout -- Defines the amount of time (in seconds) an R process with no active connections should remain open. After the last connection disconnects from an R process, this timer will start and, after the specified number of seconds, if no new connections have been created, the R process will be killed. The default value for app_idle_timeout is 5 seconds.

like image 101
greg L Avatar answered Oct 05 '22 02:10

greg L