Shiny App working on R studio server but not on shiny-server (aws-EC2)

87 views
Skip to first unread message

Martin Lavoie

unread,
Mar 8, 2018, 3:13:28 PM3/8/18
to Shiny - Web Framework for R
Hello,

I have a shiny app on a aws-EC2 instance (r4.xlarge) loading four tables from a database also on aws (postgres). 

The app works very well and loads pretty quickly when I run it on the R studio server installed on the same aws-EC2 instance.

But then when I try to visualise the app with http://XX.XXX.X.XXX:3838/my_app/ it does not work and I only get the "An error has occurred The application failed to start. The application exited during initialization."

When I look at the inspect element, I see "Failed to load resource: the server responded with a status of 500 (Internal Server Error)"

I can make the app work if I reduce the number of rows I pull with `collect(mydata, n = Inf)`. For example, 900000 instead of Inf will work.

I know I can boost the memory of the instance, but I would like to understand why it is working on the r studio server (same memory) but not with http://XX.XXX.X.XXX:3838/my_app/?

I also added this to my shiny-server.conf file with no success.

app_init_timeout 300;

app_idle_timeout 300;


Any suggestions? Did I miss something?


thank you!


Martin

DCR

unread,
Mar 9, 2018, 12:30:25 AM3/9/18
to Shiny - Web Framework for R
I recently went through the same thing. I ended up wiping my instance and starting over and still had the same issue. After searching for hours, it turned out I was missing an R package. Here's the steps I took to help debug the problem. 

1. View the shiny-server.log to see if there's any more detail

sudo cat /var/log/shiny-server.log


2. By default, shiny-server sanitizes errors. Let's fix that. 

Open config file

sudo nano /etc/shiny-server/shiny-server.conf

Add this line in your config file (I added it right after the log_dir line)

sanitize_errors false;

3. Restart the shiny server 

sudo systemctl restart shiny-server

4. Navigate to xx.xxx.x.xxx:3838/my_app/ 

You should see the same error ("An error has occurred The application failed to start. The application exited during initialization.") along with a terminal like window. It should have a lot more information on the precise error. 

Hope that helps!!

- DCR
Reply all
Reply to author
Forward
0 new messages