Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

R's shiny app goes grey when deployed, works fine locally

Tags:

r

shiny

I've created two shiny apps running on shinyapps.io and both have the same problem that I haven't been able to solve: after a few mins into an active instance of the web app (a few mins after navigating to the web app in a browser), the screen goes grey. This problem happens when I navigate to the website of the deployed app, but when I run the app from RStudio, the browser window that pops up doesn't turn grey and behaves as it should.

Many people have posted on google groups, stackoverflow, and github about this problem. I've tried all of the relevant proposed solutions for how to fix it and none of them have worked for me:

  • Screen may be turning grey because of an error in the ui or server code I wrote. The proposed solution is to run

    shinyapps::showLogs()

according to advice found here. But I've done this, and it doesn't output any error messages (see below).

  • According to the rstudio shiny help page titled 'Scaling and Performance Tuning with shinyapps.io' under the heading 'Troubleshooting' (sorry, stackoverflow won't let me post more than 1 link), the cause of problem might be that my app is using too much memory and the shinyapps.io server kills the instance. I've done the two things they suggest, increasing the size of the application instance and decreasing the number of workers per application instance. Neither have fixed the issue. I have a feeling this isn't the problem because one of my apps is extremely simple and the calculations it makes are done within a second or two when run locally. I've also checked out the memory usage of the apps on the shiny dashboard and the usage is no where near the memory limit.

Any suggestions of what might be going wrong or what to change are greatly appreciated!

Output from shinyapps::showLogs() :

2016-01-09T02:42:48.551801+00:00 shinyapps[67824]: Starting R with process ID: '26'
2016-01-09T02:42:48.556484+00:00 shinyapps[67824]: 
2016-01-09T02:42:48.556486+00:00 shinyapps[67824]: Listening on http://0.0.0.0:53774
2016-01-09T02:43:40.334353+00:00 shinyapps[67824]: R version: 3.1.2
2016-01-09T02:43:40.334428+00:00 shinyapps[67824]: shiny version: 0.11.1
2016-01-09T02:43:40.334430+00:00 shinyapps[67824]: rmarkdown version: NA
2016-01-09T02:43:40.334431+00:00 shinyapps[67824]: knitr version: NA
2016-01-09T02:43:40.334442+00:00 shinyapps[67824]: jsonlite version: 0.9.14
2016-01-09T02:43:40.334443+00:00 shinyapps[67824]: RJSONIO version: 1.3.0
2016-01-09T02:43:40.334444+00:00 shinyapps[67824]: htmltools version: 0.2.6
2016-01-09T02:43:40.582614+00:00 shinyapps[67824]: Using jsonlite for JSON processing
2016-01-09T02:43:40.586355+00:00 shinyapps[67824]: 
2016-01-09T02:43:40.586357+00:00 shinyapps[67824]: Starting R with process ID: '36'
2016-01-09T02:43:40.590767+00:00 shinyapps[67824]: 
2016-01-09T02:43:40.590769+00:00 shinyapps[67824]: Listening on http://0.0.0.0:33335
2016-01-09T03:11:48.268226+00:00 shinyapps[67824]: R version: 3.1.2
2016-01-09T03:11:48.268317+00:00 shinyapps[67824]: shiny version: 0.11.1
2016-01-09T03:11:48.268318+00:00 shinyapps[67824]: rmarkdown version: NA
2016-01-09T03:11:48.268335+00:00 shinyapps[67824]: knitr version: NA
2016-01-09T03:11:48.268336+00:00 shinyapps[67824]: jsonlite version: 0.9.14
2016-01-09T03:11:48.268337+00:00 shinyapps[67824]: RJSONIO version: 1.3.0
2016-01-09T03:11:48.268338+00:00 shinyapps[67824]: htmltools version: 0.2.6
2016-01-09T03:11:48.515347+00:00 shinyapps[67824]: Using jsonlite for JSON processing
2016-01-09T03:11:48.519056+00:00 shinyapps[67824]: 
2016-01-09T03:11:48.519058+00:00 shinyapps[67824]: Starting R with process ID: '46'
2016-01-09T03:11:48.523399+00:00 shinyapps[67824]: 
2016-01-09T03:11:48.523401+00:00 shinyapps[67824]: Listening on http://0.0.0.0:37152
2016-01-16T01:13:14.357697+00:00 shinyapps[67824]: R version: 3.1.2
2016-01-16T01:13:14.357788+00:00 shinyapps[67824]: shiny version: 0.11.1
2016-01-16T01:13:14.357790+00:00 shinyapps[67824]: rmarkdown version: NA
2016-01-16T01:13:14.357791+00:00 shinyapps[67824]: knitr version: NA
2016-01-16T01:13:14.357792+00:00 shinyapps[67824]: jsonlite version: 0.9.14
2016-01-16T01:13:14.357809+00:00 shinyapps[67824]: RJSONIO version: 1.3.0
2016-01-16T01:13:14.357811+00:00 shinyapps[67824]: htmltools version: 0.2.6
2016-01-16T01:13:14.795787+00:00 shinyapps[67824]: Using jsonlite for JSON processing
2016-01-16T01:13:14.799494+00:00 shinyapps[67824]: 
2016-01-16T01:13:14.799495+00:00 shinyapps[67824]: Starting R with process ID: '11'
2016-01-16T01:13:14.806392+00:00 shinyapps[67824]: 
2016-01-16T01:13:14.806394+00:00 shinyapps[67824]: Listening on http://0.0.0.0:49762
2016-01-17T06:48:58.595979+00:00 shinyapps[67824]: R version: 3.1.2
2016-01-17T06:48:58.596062+00:00 shinyapps[67824]: shiny version: 0.11.1
2016-01-17T06:48:58.596064+00:00 shinyapps[67824]: rmarkdown version: NA
2016-01-17T06:48:58.596065+00:00 shinyapps[67824]: knitr version: NA
2016-01-17T06:48:58.596077+00:00 shinyapps[67824]: jsonlite version: 0.9.14
2016-01-17T06:48:58.596078+00:00 shinyapps[67824]: RJSONIO version: 1.3.0
2016-01-17T06:48:58.596079+00:00 shinyapps[67824]: htmltools version: 0.2.6
2016-01-17T06:48:58.999625+00:00 shinyapps[67824]: Using jsonlite for JSON processing
2016-01-17T06:48:59.003284+00:00 shinyapps[67824]: 
2016-01-17T06:48:59.003287+00:00 shinyapps[67824]: Starting R with process ID: '11'
2016-01-17T06:48:59.010065+00:00 shinyapps[67824]: 
2016-01-17T06:48:59.010067+00:00 shinyapps[67824]: Listening on http://0.0.0.0:37097

Here's an example of one of the problematic shiny apps: https://rosemarie-p-b-scott.shinyapps.io/OM_2266/

like image 844
sbpr Avatar asked Jan 17 '16 18:01

sbpr


People also ask

Why does my app work locally but not on my Shiny server?

Your application may be dependent on packages that are installed and loaded in your environment, but aren't installed for the correct user on the Shiny Server. Make sure that all necessary packages are installed for the same user set under run_as in your Shiny Server configuration file.

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.

Why does Shiny app disconnect 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.


Video Answer


1 Answers

I don't know what exactly your app should be doing, but it seems to work fine for me as well. As far as I can tell your log doesn't show any errors either.

Might this be a timing issue? After 15 minutes of inactivity your app is put to sleep and when you surpass your active hours with a free account your app will not work either. Checkout the shinyapps user guide section 3.3 http://docs.rstudio.com/shinyapps.io/applications.html#application-life-cycle for more details

After the time out I see a greyed out version of the app screen with a message "Disconnected from the server" and a "reload" button. Is that how it looks to you?

I don't know how this looks when you use up all your active hours and I'm not going to try. You have to test this yourself.

like image 183
Etienne Moerman Avatar answered Nov 09 '22 05:11

Etienne Moerman