ERR_EMPTY_RESPONSE shiny server - r

I am currently hosting a number of shiny apps on a shiny-server open source on a centos7 distro. All the apps were/are working fine but for one of the apps when I try to go to the url I get the following message:
This page isn't working
<ip.address> did not receive any data.
ERR_EMPTY_RESPONSE.
All the other shiny apps hosted on the same shiny server are working just fine. I checked /var/log/shiny-server and there is no log file for this App. As the other apps are working fine, I dont think its a port issue.
The only difference between other apps and this one is that it was used the most by its users. Is there some restriction/limit on shiny-server for runtime? I can't figure out what the problem is. The app runs fine on RStudio Server and if I copy it into a new directory in /srv/shiny-server/ with a different name, it also works fine.

A couple of thoughts:
If a process closes successfully, then shiny deletes the log files. So it's possible you may be missing some log files. You may override this with preserve_logs, see here. Your users may be triggering some error through their interactions with the app, but other sessions are successful, so shiny deletes the log files.
Shiny creates one process per app be default, but an unlimited number of session (see here). This means that if your app is the one that is used the most by users, each user is generating a new session. And if the app is computationally intensive, then some of the user sessions may be getting backlogged which might trigger the ERR_EMPTY_RESPONSE. You can fix this by using Docker to spin up a process for each user. Here are some options, I've found shinyproxy to be the most intuitive.

Related

Automatically restart Shiny apps after server reboot

I have a Shiny application that needs to load into memory some fairly large data sets. To save the users some time when browsing to the dashboard, I set the app_idle_timeout to zero (using the community version of the Shiny server application), as suggested in the docs. This works as expected.
However, the underlying data needs to be refreshed daily. Hence, what I would like to do is setting up a cron job that reboots the shiny server (or stops the relevant sessions) every day at 3am and then automatically initiates a new R session so that the data in the global.R is loaded into memory and the dashboard ready to consume instantly.
What I do not understand is how to initiate a particular Shiny application from terminal, i.e. mimic what happens when browsing to the URL of this app on the Shiny server.
Any suggestion would be greatly appreciated.

Shiny server on EC2: URL lists folder content instead of displaying app

[Sorry, newbie here!]
I've just installed R server, shiny server on an ubuntu EC2 instance. I have left the shiny-server.conf intact, except that I added: preserve_logs true;. The sample app was working fine.
I have removed /srv/shiny-server/index.html and /srv/shiny-server/sample-apps.
I have linked my app files from my /home/myapp directory to /srv/shiny-server/myapp. The app files consists of a single apps.R, a footer.html, and a small dataset .Rds, and a www/style.css file.
When I navigate to http://[myip]:3838/ the only thing is the directory listing; the only folder is : myapp. When I click to http://[myip]:3838/myapp/ , I see the directory listing as well. That is, I see the content, and I can download each of them. BUt I see no evidence of the app running. If I click on apps.R, my browser downloads the file.
PS: the app works fine when tested in Rstudio, or deployed on Shinyapps.io
If anyone from the future reads this, I wish you heard the loud headslap when I realized my app single-file should be called app.R, not apps.R (which makes a lot of sense in retrospect).

Shiny R app error "too long to respond" but works from different directory

My organization runs Shiny apps over a server that pulls the app.R files from a directory. When I go to the internal site for the directory I get an error: "An error has occurred The application failed to start. The application took too long to respond."
Runs local, and copy/paste from new folder in different directory as well too. Unfortunately cannot provide reproducible example sorry.
This has nothing to do with shiny in this case.
You should check with your company. They may have some identification
problem or an identity management software that is blocking the access from your shiny app. This is why your shiny app waits so long to have access to the directory but fails at the end.
In your place, I would check if there are any security barriers made
by the company to secure their files. I am quite sure this is the
problem and you have to request or ask for permissions to have access from shiny to that directory.
--------- UPDATES for comments ---------
If you tried the same exact app with another directory and it worked well, then it's definitely a problem with the directory and not shiny. Most probably it should be with access permissions monitored by the IS admin. So yes, your understanding is correct!
In order to avoid any problem in the future, keep everything as much as possible inside UI and server and avoid outside processing if you can. It's a bad practice IMHO.

Running app successful in R studio but not in Shiny server

My operation system is ubuntu.
I run a shiny app successfully in rstudio.
I have copied all files in the shiny server file. But when I try to run the app from shiny server I see in browser this error:
ERROR: An error has occurred. Check your logs or contact the app author for clarification.
However when I go to logs I can't find log for the specific app.
Is there any workaround for that kind of issues?
I can't comment so I'm putting this as an answer. Are all of the packages your app needs installed on the server?
Logs are not stored if the R process end successfully, and if I remember right that includes when packages are not installed.
From the Shiny Server Configuration Guide
A log file will be created for each R process when it is started.
However, if a process closes successfully, the error log associated
with that process will be automatically deleted. The only error log
files that will remain on disk are those associated with R processes
that did not exit as expected.
You can override this behavior using the preserve_logs configuration
option. If you set preserve_logs true; in your configuration file,
Shiny Server will never delete the logs from your R processes,
regardless of their exit code. Be aware that this will cause log files
to accumulate very quickly on a busy server. This setting is only
recommended for debugging purposes; if it were to be enabled on a
production server, you would need to pay close attention to the
rotation and archiving of logs to prevent your file system becoming
overwhelmed with log files.

Shiny Server User/UserGroup

Please suggest a clean(er) way of adding a user (like myself) to Shiny Server running on Ubuntu. I found this link: Setting up shiny User permissions but would like more advice on this. And I don't want to host RStudio server, just want to host Shiny server. Also can I run Tomcat along with Shiny server on the same machine?
I think you may be misunderstanding what that link is saying. You're not setting up different users for the Shiny server, you're setting up users on your computer, and managing them in such a way that you keep track of permissions for files you create on the computer. The important thing is to make sure the "shiny" user on your computer (which will be the one hosting your shiny server apps, unless you modify the default settings) has the correct permissions to access the files it will need when running those apps.
When you run a Shiny app, you won't be logged in as a user per se, rather the "shiny" user will host the computation for you, and deliver any output to you through your browser interface.
To my knowledge, unless you're using Shiny Server Pro, you won't have the ability to specify different users when using the apps (this is different to a "session", which is another topic).
When you create a shiny app, and install it (by moving it to the "/srv/shiny-server" folder), you'll need to make sure the user "shiny" on your computer has read access to that file at the very least. If your app involves reading data files from your computer, make sure the "shiny" user has read access to those too. If your app involves writing to files on our computer, make sure the "shiny" user also has write permission for those files.

Resources