Skip to content

[Bioc-devel] bioconductor AMI & shiny app

4 messages · Robert Castelo, Dan Tenenbaum

#
hi,

i'm trying to use a shiny app through AWS and the bioconductor AMI, but 
i cannot make it work.

i have created a security group in AWS that has open the 8787 and 6219 
ports, the former for RStudio and the latter to access the shiny app. 
this is the command-line output from my desktop interrogating how the 
security group is configured:

$ aws ec2 describe-security-groups --group-names test | ./JSON.sh -b
["SecurityGroups",0,"Description"]      "test"
["SecurityGroups",0,"IpPermissions",0,"ToPort"] 22
["SecurityGroups",0,"IpPermissions",0,"IpProtocol"]     "tcp"
["SecurityGroups",0,"IpPermissions",0,"IpRanges",0,"CidrIp"]    "0.0.0.0/0"
["SecurityGroups",0,"IpPermissions",0,"FromPort"]       22
["SecurityGroups",0,"IpPermissions",1,"ToPort"] 3838
["SecurityGroups",0,"IpPermissions",1,"IpProtocol"]     "tcp"
["SecurityGroups",0,"IpPermissions",1,"IpRanges",0,"CidrIp"]    "0.0.0.0/0"
["SecurityGroups",0,"IpPermissions",1,"FromPort"]       3838
["SecurityGroups",0,"IpPermissions",2,"ToPort"] 6219
["SecurityGroups",0,"IpPermissions",2,"IpProtocol"]     "tcp"
["SecurityGroups",0,"IpPermissions",2,"IpRanges",0,"CidrIp"]    "0.0.0.0/0"
["SecurityGroups",0,"IpPermissions",2,"FromPort"]       6219
["SecurityGroups",0,"IpPermissions",3,"ToPort"] 8787
["SecurityGroups",0,"IpPermissions",3,"IpProtocol"]     "tcp"
["SecurityGroups",0,"IpPermissions",3,"IpRanges",0,"CidrIp"]    "0.0.0.0/0"
["SecurityGroups",0,"IpPermissions",3,"FromPort"]       8787

i have updated the shiny-server in the bioc AMI to the lastest version. 
this is the command-line output from the AWS instance running the bioc AMI:

$ tail -n 5 /var/log/shiny-server.log
0[2014-05-21 13:37:59.867] [INFO] shiny-server - Shiny Server 
v1.1.0.10000 (Node.js v0.10.21)
[2014-05-21 13:37:59.888] [INFO] shiny-server - Using pidfile 
/var/run/shiny-server.pid
[2014-05-21 13:37:59.891] [INFO] shiny-server - Using config file 
"/etc/shiny-server/shiny-server.conf"
[2014-05-21 13:37:59.950] [WARN] shiny-server - Running as root 
unnecessarily is a security risk! You could be running more securely as 
non-root.
[2014-05-21 13:37:59.954] [INFO] shiny-server - Starting listener on 
0.0.0.0:3838

i connect to R studio through the 8787 port and then i do the following 
using the code from the example of the 'runApp()' man page:

library(shiny)

runApp(list(
        ui = bootstrapPage(
          numericInput('n', 'Number of obs', 100),
          plotOutput('plot')
        ),
        server = function(input, output) {
          output$plot <- renderPlot({ hist(runif(input$n)) })
        }
      ), host="ec2-xx-xx-xx-xx.compute-1.amazonaws.com", port=6219)

where "ec2-xx-xx-xx-xx.compute-1.amazonaws.com is the public DNS of my 
instance.

the server starts fine with the message "Listening on http://ec2-xx 
..etc", however, the window opens directly with the error message "The 
system returned: (111) Connection refused"

if instead of using the public DNS as host i use the IP address in the 
"inet addr" field from the eht0 entry of the 'ifconfig' unix command it 
gives a "timeout" after a few minutes and if i use the IP address 
resulting from concatenating xx.xx.xx.xx in the public DNS name then it 
says "Failed to create server".

to make it more puzzling if i connect with the browser to the port 3838 
of the public DNS server, i.e., 
ec2-xx-xx-xx-xx.compute-1.amazonaws.com:3838 then it says "Welcome to 
Shiny Server!" and the example app works perfectly.

so it seems that i'm doing something wrong when starting the server from 
RStudio via runApp().

i've been googling a lot and i think i have everything in place so i 
wonder whether something might be wrong in how the bioc AMI is 
configured. before i updated the shiny-server even the last option 
wasn't working, but i don't know what else could i do system-wide to try 
to fix this problem.

any hint will be very much appreciated,

thanks!!
robert.
#
Hi Robert,

----- Original Message -----
I started an instance of the BioC 2.14 AMI (is that the one you are working with?) and updated to the latest
shiny server (apologies for the old one being on there).

Looks like by default it listens on port 3838 (see /etc/shiny-server/shiny-server.conf) so I added that to my security group and went to http://ec2XXXXX.compute-1.amazonaws.com:3838 and it worked. 

So I will update that AMI to use that version of shiny server by default.
I got this to work if I specified host as the "private IP" as displayed in the aws console (an IP address that for me anyway starts with 10.182).

I got a message saying the popup was blocked, but I think that's ok, because it was trying to go to the wrong URL anyway (that internal IP which is not accessible from outside ec2). But in another window I went to

http://ec2-XXXXX.compute-1.amazonaws.com:6219 

and the shiny app worked.

Dan
#
hi Dan,
On 05/21/2014 10:29 PM, Dan Tenenbaum wrote:
yes, that was it.
yes, it also worked for me at port 3838.
thanks for trying it out, the description of what you did gave me a 
hint, i was not trying to combine an address to launch the shiny app 
with a different address in the browser to connect. now, i could make it 
work by doing exactly how you say, using the private IP in the 'host' 
argument of 'runApp()' and replacing that IP in the browser by the 
public DNS name.

this procedure, however, looks a bit cumbersome to me, specially if a 
non-expert user is supposed to use the shiny app. do you know whether it 
is possible that the browser window opens automatically with the public 
DNS name?

thanks!
robert.
#
----- Original Message -----
Note that the launch.browser argument to runApp() "can also be a function to call with the
application's URL". So maybe this function could translate the private IP to the public DNS (actually, based on the Details section of runApp(), it seems like you could use 0.0.0.0 instead of the private IP).

The function could use instance metadata (http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/AESDG-chapter-instancedata.html) to find out the public DNS name and construct a URL, then start a browser window pointing to that URL. If you provide this function, users won't have to know what it does. 

I would also post on the shiny google group (https://groups.google.com/group/shiny-discuss) and ask them if they might have a more elegant solution, or would be interested in adding some EC2 support. It shouldn't be too difficult.

Dan