3

I maintain a Dockerised shiny R hosted in Ubuntu with Ngnix web-server running in port 5050. It works fine, however greyed out after inactivity for some time.

To circumvent this I modified the proxy_read_timeout parameter default file in /etc/nginx/sites-available as below

location /XXX/YYY/ {
      rewrite ^/XXX/YYY/(.*)$ /$1 break;
      proxy_pass http://localhost:5050;
      proxy_redirect http://localhost:5050/ $scheme://$host/XXX/YYY/;
      proxy_http_version 1.1;
      proxy_set_header Upgrade $http_upgrade;
      proxy_set_header   Connection "upgrade";      
      proxy_read_timeout 20d;
      proxy_buffering off;
    }

I also increased numbers in all below files

/proc/sys/net/ipv4/tcp_keepalive_time
/proc/sys/net/ipv4/tcp_keepalive_intvl
/proc/sys/net/ipv4/tcp_keepalive_probes
/proc/sys/net/ipv4/tcp_retries2

Additionally, I added below lines /etc/nginx/nginx.conf

http {
     fastcgi_read_timeout 1d;
     proxy_read_timeout 1d;
}

Furthermore, I added below lines of code in server.R

output$clock = renderText({
                invalidateLater(5000)
                Sys.time()
            })  

But unfortunately, nothing solved my problem. However I noticed that when I use ip-address:5050 to run my app I don't see greyed out, but when I use ip-address/XXX/YYY then it happens.

I am using Cloudflare free subscription - dose it have any impact on above issue? If this is the case then what is the solution?

Bogaso
  • 2,838
  • 3
  • 24
  • 54
  • Have you looked at /etc/shiny-server/shiny-server.conf? See https://docs.rstudio.com/shiny-server/#app_idle_timeout and the next couple app_session_timeout and http_keepalive_timeout. Tweaking these might help. – Eli Berkow Jun 28 '19 at 09:05
  • @Eli - as I pointed in my post, if I use ip-address:5050, I dont get greyed out. So I do not think it is Shiny app's issue. Anyway, I changed the values of app_idle_timeout and http_keepalive_timeout in shiny-server.conf to some big number - But still I get greyed out. Please note that the default value for app_session_timeout is 0 which means "The number of seconds after which an idle session will be disconnected. If 0, sessions will never be automatically disconnected" - So I dont think this parameter matters to my problem – Bogaso Jun 28 '19 at 12:05
  • That could be. After any changes to shiny-server.conf just make sure you restart the shiny server for the changes to take effect. Sorry, I have no other suggestions. good luck! – Eli Berkow Jun 28 '19 at 12:47
  • 1
    Have you tried [this](https://stackoverflow.com/questions/54594781/how-to-prevent-a-shiny-app-from-being-grayed-out/54604662#54604662) ? – Stéphane Laurent Jun 29 '19 at 04:37
  • @ Stéphane this appears to be working for me thanks – Bogaso Jun 29 '19 at 08:41

0 Answers0