Shiny Server Error

2,905 views
Skip to first unread message

Dawg

unread,
Jan 28, 2013, 6:12:27 PM1/28/13
to shiny-...@googlegroups.com
Hello -

my Shiny app requires me to load a lot of data and to extensive computations in the beginning. I get the following error message from Shiny Server:

An error has occurred
The application failed to start.
The application took too long to respond.

Works though when I build everything without Shiny server as a local app.

Thanks,
Dawg

Joe Cheng

unread,
Jan 30, 2013, 1:33:15 AM1/30/13
to shiny-...@googlegroups.com
In an ideal world, you could simply speed up the startup of your app. One way to do this is to perform all the data loading/calculating logic once, and use save() or save.image() to save part or all of your global environment to an .RData file, and load that .RData file on startup of your Shiny app (in global.R).

In case that is not possible for whatever reason, I have implemented some additional config options to allow you to configure the amount of time Shiny Server will wait for your app to start up. It is on a branch though, I need to wait for code review and testing to merge it into the main repo. In the meantime you can install it with:


Josh told me about your case over e-mail and it sounds like not only would you want to have very long timeouts on startup, but also, to keep the app running even after all users leave so you don't have to pay that long startup cost again when a new user logs on. That is configurable in this build as well.

The two new config file directives are called startup_timeout and shutdown_delay. A value of -1 will make either value infinite; a positive float will be interpreted as number of seconds.

In case you have not created a config file and are just using the default, you want your config file to look like this:

run_as shiny;
startup_timeout -1;
shutdown_delay -1;

server {
  listen 3838;

  location / {
    site_dir /var/shiny-server/www;
    log_dir /var/shiny-server/log;
    directory_index on;
  }
}

Hope that helps.


--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Dawg

unread,
Jan 30, 2013, 2:32:25 AM1/30/13
to shiny-...@googlegroups.com
Joe,

fantastic! I can't thank you enough for your speedy response and code posting.

Amazing,
Dawg

Dawg

unread,
Jan 30, 2013, 3:40:50 AM1/30/13
to shiny-...@googlegroups.com
Joe - I get the following error, it first loads all the data and then at html access crashes.

:/var/shiny-server/www/KatRisk$ sudo shiny-server
[2013-01-30 00:22:56.460] [INFO] shiny-server - Shiny Server v0.3.0 (Node.js v0.8.18)
[2013-01-30 00:22:56.461] [INFO] shiny-server - Using config file "/etc/shiny-server/shiny-server.conf"
[2013-01-30 00:22:56.487] [INFO] shiny-server - Starting listener on 0.0.0.0:3838
[2013-01-30 00:26:05.634] [ERROR] shiny-server - Uncaught exception: Error: Parse Error

/usr/lib/node_modules/shiny-server/lib/main.js:201
  throw err;
        ^
Error: Parse Error
    at Socket.socketOnData (http.js:1447:20)
    at TCP.onread (net.js:404:27)

Winston Chang

unread,
Jan 30, 2013, 9:31:19 AM1/30/13
to shiny-...@googlegroups.com
Regarding the slow load issue: if the slow part involves loading and/or processing a large data set, and if the data is common to each user session, you can restructure your code so that it is run once, when the Shiny app is started, instead of each time a user connects.

For example:

# A read-only data set that will load once, when Shiny starts, and will be
# available to each user session
bigDataSet <- read.csv('bigdata.csv')

shinyServer(function(input, output) {
  # Runs each time someone starts a session
  anotherDataSet <- read.csv('otherdata.csv')

})

See this page for more information about scoping:


-Winston


Joe Cheng

unread,
Jan 30, 2013, 10:27:19 AM1/30/13
to shiny-...@googlegroups.com
I'll follow up with you off-list.

Andreas

unread,
Feb 6, 2013, 9:03:20 PM2/6/13
to shiny-...@googlegroups.com
I get the same error, but even with the simple example in the tutorial.
Everything worked fine this morning and offline everything works fine and now i get: 

An error has occurred
The application took too long to respond.
listening on port 8100

Andreas

unread,
Feb 7, 2013, 4:37:01 PM2/7/13
to shiny-...@googlegroups.com
ok. Nowit works again (without doing anything) but still it works :)

Joe Cheng

unread,
Feb 7, 2013, 6:36:21 PM2/7/13
to shiny-...@googlegroups.com
It's possible your computer is configured to use a proxy server for all HTTP requests, including those to localhost. If so, your web browser and/or OS should allow you to bypass the proxy for certain hosts, and you should add localhost and/or 127.0.0.1 and/or 127.0.1.1 to that list. Do a google search for "bypass proxy" plus your browser and/or OS and you should be able to find a lot of instructions for doing that.


--

Mike Jiang

unread,
Mar 25, 2013, 12:34:36 PM3/25/13
to shiny-...@googlegroups.com
I've got the same problem of "The application took too long to respond." due to the initial loading of the big data. After I installed https://github.com/jcheng5/shiny-server/archive/configurable-timeouts.tar.gz to add timeout configuration,but I ran into  "not compatible with INTSXP" error.  Could you please give me some advice on this?

P.S.I am using R Under development (unstable) (2012-06-23 r59613) -- "Unsuffered Consequences". (everything was working fine until I start to test it with the bigger dataset.

Thanks!

Mike

Joe Cheng

unread,
Mar 25, 2013, 1:06:42 PM3/25/13
to shiny-...@googlegroups.com
Sorry, that branch wasn't updated to work with the latest versions of Shiny. I just updated it. Try installing shiny-server from that same URL again and it should work.

Mike Jiang

unread,
Mar 25, 2013, 3:36:32 PM3/25/13
to shiny-...@googlegroups.com
It works great! Thanks Joe!

Mike Jiang

unread,
May 1, 2013, 1:22:23 PM5/1/13
to shiny-...@googlegroups.com, wenxin...@gmail.com
Hi,Joe,

It worked well until I started to deploy the app with both "site" and "Autouser" methods.  After a couple of days of initial visiting the app, I tried to revisit the app by opening URL in the browser, instead of using the existing R session, it forked a new one. And the old R session became the dangling session.  Is this a bug or something I didn't configure properly?

ubuntu 12.04
R version 2.15.3 (2013-03-01) -- "Security Blanket"
shiny_0.5.0

And here is my /etc/shiny-server/shiny-server.conf:
##################################
run_as shiny;
 log_dir /var/shiny-server/log;

 startup_timeout -1;
 shutdown_delay -1;

    server {
      listen 80;

    location / {
        directory_index on;
         user_apps on;
     }
    location / {
      directory_index on;
       site_dir /var/shiny-server/www;
      }
    }
################################

Thanks a lot!

Mike

BE

unread,
May 2, 2013, 7:36:29 AM5/2/13
to shiny-...@googlegroups.com, wenxin...@gmail.com
Hi,

I have a similary problem as Mike.
My part, i have many packages loading at the starting of the apps (so the .Rdata file not works for my pbl, i think). It take a long time and prompt this error : "The application took too long to respond"; whereas when i use in local "runApp()" it's working well after the first run (which takes some time).

So i tried to use your (Joe) "trick".
1/ sudo npm install -g https://github.com/jcheng5/shiny-server/archive/configurable-timeouts.tar.gz
2/ and modify the file as :

run_as shiny;
startup_timeout -1;
shutdown_delay -1;

server {
  listen 3838;

  location / {
    site_dir /var/shiny-server/www;
    log_dir /var/shiny-server/log;
    directory_index on;
  }
}

Is this solution is still available ? Because after those 2 steps, i always have the error prompt...
Thank you for help. And thank you for shiny : it's very usefull !!

Etienne

Joe Cheng

unread,
May 2, 2013, 1:53:24 PM5/2/13
to shiny-...@googlegroups.com, wenxin...@gmail.com
Etienne, did you restart shiny-server after doing that? (If you've got it configured using upstart, it's "sudo restart shiny-server")

Mike, I'm not sure why it didn't use the old one--unless the shiny-server process was restarted...? Let me know if this happens reproducibly and if so, I will try it myself.

Brian Bot

unread,
Sep 26, 2013, 3:31:23 PM9/26/13
to shiny-...@googlegroups.com, wenxin...@gmail.com
Hi Joe. Any change we can get the configurable timeouts branch updated again, as was done back in March?

Joe Cheng

unread,
Sep 26, 2013, 5:26:43 PM9/26/13
to shiny-...@googlegroups.com, Mike Jiang
Configurable timeouts are a feature of the master branch now. However, the instructions for building and installing Shiny Server have not been updated since we did widespread refactoring this summer. The next release of Shiny Server will bundle its own copy of Node.js and be installed using a .deb or .rpm. We don't have a date yet for when this release will be, but it's high on our priority list.

Is there a particular problem you're having with the current version of shiny-server that you're running?

Brian Bot

unread,
Sep 26, 2013, 6:44:32 PM9/26/13
to shiny-...@googlegroups.com, Mike Jiang
Have updated my version of shiny-server on an Ubuntu machine using:

sudo npm install -g shiny-server


My config file looks like this:

startup_timeout -1;
shutdown_delay -1;

server{
  listen 3838;

  location /users {
    user_apps on;
    directory_index on;
  }

}

I have also tried very large times instead of -1, however infinite times would be ideal such that large initial data loads (1) complete; and (2) do not have to be repeated.

Thanks much.

Brian Bot

unread,
Sep 26, 2013, 6:53:39 PM9/26/13
to shiny-...@googlegroups.com, Mike Jiang
Sorry, meant to also say that this did not seem to work for known-functional longer-running apps -- while shorter run-time apps like 01_hello example work just fine.

Thanks again for the help.
Reply all
Reply to author
Forward
0 new messages