18

I am trying to host an app over the web using R, shiny and shiny-server. As a preface, I have only used Linux OS (of any flavor) for a day-or-two and have no networking experience. So please bear with me. And I apologize in advance if I've overlooked something that is incredibly simple.

I followed the examples given in the links below to install Ubuntu 12.04, R (precise), shiny and shiny-server.

All the commands execute fine with no complaints. Ubuntu appears to have installed fine. R runs fine. All the R libraries install. I can host shiny applications locally using runApp and runGist pointing to appropriate file locations.

As a test, I copy the shiny examples to shiny-server/www folders:

sudo cp -R /usr/local/lib/R/site-library/shiny/examples /var/shiny-server/www/

If I open R in the terminal, and run the following code. Things run fine.

runApp("/var/shiny-server/www/examples/01_hello/")

This time the app runs in http://localhost:4251/. One weird thing I notice is that if I quit R and run the same code in a new session, the app runs in a different "port" (i.e. not 4251). Maybe this is usual behavior in Ubuntu??? But coming from Windows I am used to the app always running in the same http://localhost:8100/.

Now when I try:

sudo start shiny-server. And try to open the same example over the web (i.e. not locally in R). One thing I notice is that the process always starts at a different "port". This time it is shiny-server start/running, process 4463. But this process number changes with every sudo start shiny-server and sudo stop shiny-server sequence. And is not 3838 like I would expect from the example documents cited above. Is this normal?

With the server started, if I try (replacing hostname with my IP address) to enter the following URL (in Firefox) I get:

  • http://<hostname>:3838/examples/ Results in "Page not found Error".
  • http://<hostname>:4463/examples/ Results in "Unable to Connect to Server Error"

Do the hints given above provide enough information for determining what I am doing wrong in setting up shiny-server?

Do I need other software/libraries installed besides Ubuntu 12.04, R, shiny, shiny-server, node.js, upstart script, etc. listed in the posts above?

I am running all of the above off a standalone desktop style machine, itself part of a larger Departmental network (at University). Is my departments network firewall, or my personal firewall blocking my access? How would I disable/adjust settings if this is the case in Ubuntu?

Really I'm a rookie and have no idea why it's not working, and would appreciate any help the group could provide. Thanks in advance, and below is the version of R, shiny and shiny-server I am using:

> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-pc-linux-gnu (64-bit)

locale:
[1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
[3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
[5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
[7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
[9] LC_ADDRESS=C               LC_TELEPHONE=C            
[11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] rCharts_0.3.51 shiny_0.8.0   

loaded via a namespace (and not attached):
[1] bitops_1.0-6    caTools_1.16    digest_0.6.3    grid_3.0.2     
[5] httpuv_1.2.0    lattice_0.20-24 plyr_1.8        Rcpp_0.10.6    
[9] RJSONIO_1.0-3   tools_3.0.2     whisker_0.3-2   xtable_1.7-1   
[13] yaml_2.1.8

This is where/how I got shiny-server http://www.rstudio.com/shiny/server/install-opensource

Chris
  • 3,401
  • 5
  • 33
  • 42
  • Can you run `netstat | less` to check if anything is running in port 3838 by any chance? – tcash21 Dec 04 '13 at 21:39
  • 2
    edit the `shiny-server` config file. usually `/etc/shiny-server/shiny-server.conf`. See http://rstudio.github.io/shiny-server/latest/#default-configuration – Jake Burkhead Dec 04 '13 at 21:41
  • @JakeBurkhead I do not see the location `/etc/shiny-server/shiny-server.conf` after following the install instructions. A file with a similar name (not sure contents) is located at `etc/init/shiny-server.conf`. All that is in this file is the following code: `# shiny-server.conf description "Shiny application server" start on runlevel [2345] stop on runlevel [016] limit nofile 1000000 1000000 exec shiny-server --pidfile=/var/run/shiny-server.pid >> /var/log/shiny-server.log 2>&1 respawn `. My file unfortunately does not look like the one at the Rstudio link provided. Thoughts? – Chris Dec 05 '13 at 00:18
  • @tcash21 I ran the code `netstat | less` in the terminal and got about 20+ pages of output printed to terminal. Is it possible to print to file and search for the port number 3838 from within the printed text. Given the large amount of output it wouldn't surprise me if something else is running on port 3838. – Chris Dec 05 '13 at 00:23
  • 1
    Try creating `/etc/shiny-server/shiny-server.conf`. It's been a while since I've worked with shiny but IIRC when you start the server it will automatically look there. If that file doesn't exist it will go based on defaults. This is what mine looks like http://pastebin.com/PrREthda. Let me know if this works and I'll add it as an answer – Jake Burkhead Dec 05 '13 at 01:21
  • Regarding that `shiny-server start/running, process 4463` message, it sounds more like `4463` is the `PID` of the `shiny-server` process and not the port to which it listens. – Guillem Vicens Dec 05 '13 at 07:18
  • @GuillemVicens. Thank you for the explanation re: "port" and "process". Still trying to piece this whole thing together. – Chris Dec 05 '13 at 14:01
  • @JakeBurkhead. When I run create the `/etc/shiny-server/shiny-server.conf` file and try to listen on any port (80, 3838, etc.) I get the following error when I run `sudo shiny-server` in the terminal: `[2013-12-05 09:31:12.169] [ERROR] shiny-server - HTTP server error (0.0.0.0:3838): listen EADDRINUSE `. Any idea what this means? – Chris Dec 05 '13 at 14:43
  • @Chris that means another program is already using that port. look at `sudo netstat -l -p` to see which program is listening to port 80 or `*:http`. My guess is that its `apache2` so `sudo service apache2 stop` should kill it – Jake Burkhead Dec 05 '13 at 15:09
  • Hi @JakeBurkhead. Sorry if this is the most basic question about Shiny. Is Ubuntu 12.04 enough to run shiny server and host my app over the web? Or do I need to configure Ubuntu and all of the other software that makes a web server?...Like Apache, MySQL, PHP, etc. Whn I type `apache2` in terminal I get a message saying it is not installed? Thanks...I have NO networking background and am just trying to follow the instructions word for word as best I can. – Chris Dec 05 '13 at 22:56
  • Basically, if I come from a Windows environment. With no Linux server. What would be the best available step-by-step resources to first configure the Linux Ubuntu server, then install R, shiny, shiny-server, etc. Then configure file directories etc. so the server knows where my app is and can be hosted on the web. Seriously, I can get it to run locally (Windows, Mac, Ubuntu) using `runApp()` but am totally lost on my third install Ubuntu from scratch try at this. Thanks so much for any help you can provide. – Chris Dec 05 '13 at 23:01
  • @Chris I believe Ubuntu 12.04 + node (nodejs) + R (of course) is all you need. I was only guessing that it was apache2 using port 80. You'd have to look at the output of `netstat` to find out for sure. These comments are getting a bit too long. Feel free to email me at jlburkhead@ucdavis.edu with any further questions. Again I'll warn that I haven't used shiny for at all for a few months. The shiny google group https://groups.google.com/forum/#!forum/shiny-discuss is very good (probably better than SO) for these kind of hosting questions – Jake Burkhead Dec 06 '13 at 00:39

1 Answers1

10

Sorry you're having trouble. I think (hope) you'll have more luck with the precompile binaries we've prepared for Ubuntu 12.04. You can grab them from our download page.

The goal of the binaries is to simplify the installation process for users. Be sure to follow the instructions in our official guide which should walk you through the process.

If you do need to customize the port, you can override the default configuration file by placing an alternate file in /etc/shiny-server/shiny-server.conf, as some commenters suggested. If you want to use the default config file to get you started, you can copy it there using the command:

sudo cp /opt/shiny-server/config/default.config /etc/shiny-server/shiny-server.conf

When you restart/reload Shiny Server, it should pick up that configuration file and use whatever settings you specify there (like custom ports).

amc
  • 263
  • 3
  • 19
Jeff Allen
  • 17,277
  • 8
  • 49
  • 70
  • And sorry for the mixup with the Ubuntu step-by-step instructions. I added a big warning to try to help other who come across that page. – Jeff Allen Dec 09 '13 at 05:18
  • 1
    Thanks Jeff. Using some parts of Huidong's blog and the Shiny Server step by step instructions and the new pre-compiled binaries I was able to get things to work!! Keep up the great work. – Chris Dec 16 '13 at 16:40