3

I'm new to Shiny, but not new to R. Because of work, I'm now doing R development in RStudio server. It is running on Google Compute Engine, if that makes a difference. RStudio server runs just fine, but Shiny is having problems.

After installing shiny, I ran the example command:

runExample("01_hello")

At first, this brought up the Hello Shiny! app, but everything was grey. I restarted RStudio, cleaned the workspace, and ran the command again. Now a window pops up, but it immediately disappears. I tried restarting RStudio server, and running in a different browser, but the behavior continues.

I've tried quickly clicking the "Open in Browser" button, and that gets me a tab in my browser that's grey, just like before I restarted.

Any suggestions? Thank you.

EDIT:

When I launch the example, the RStudio console gives:

Listening on http://127.0.0.1:4096

And just sits there until I press esc.

The IE Console gives no errors (although I'm also not sure if I'm using it right--not a web guy, sorry).

The Chrome console does give an error:

'webkitRequestAnimationFrame' is vendor-specific. Please use the standard 'requestAnimationFrame' instead.

Which has a link to VM320:6635 which reads:

function _b(b,c){var d=b;var e=Gni(function(){var a=wj();d.Df(a)});return $wnd.webkitRequestAnimationFrame(e,c)}

Michael Sherman
  • 523
  • 2
  • 5
  • 16

3 Answers3

2

I had the same problem after installing RStudio Server and Shiny Server on my VPS, then tried to configure an Apache proxy, so that I can use www.example.com/rstudio to reach the IDE instead of the default www.example.com:8787.

I did it wrong at first, and had the same problem as you, but here I found the correct solution: https://support.rstudio.com/hc/en-us/articles/200552326-Running-with-a-Proxy

The direct cause was the missing websocket proxy configuration:

ProxyPassMatch ^/rstudio/p/([0-9]+)/(websocket|.*/websocket)/$ ws://localhost:8787/p/$1/$2/
guest
  • 21
  • 2
1

To test whether the problem is in RStudio server or in somewhere else run this single file app in R(copy paste to R terminal):

library(shiny)
server <- function(input, output) {
  output$distPlot <- renderPlot({
    hist(rnorm(input$obs), col = 'darkgray', border = 'white')
  })
}

ui <- shinyUI(fluidPage(
  sidebarLayout(
    sidebarPanel(
      sliderInput("obs", "Number of observations:", min = 10, max = 500, value = 100)
    ),
    mainPanel(plotOutput("distPlot"))
  )
))

shinyApp(ui = ui, server = server)

I found google group discussion Rstudio server problem so it is possible that it is some kind of compatibility problem.

Mikael Jumppanen
  • 2,436
  • 1
  • 17
  • 29
  • Thanks @Mikael. I ran the code and: `Listening on http://127.0.0.1:5584 /usr/bin/xdg-open: 1: eval: www-browser: not found /usr/bin/xdg-open: 1: eval: links2: not found /usr/bin/xdg-open: 1: eval: elinks: not found /usr/bin/xdg-open: 1: eval: links: not found /usr/bin/xdg-open: 1: eval: lynx: not found /usr/bin/xdg-open: 1: eval: w3m: not found xdg-open: no method available for opening 'http://127.0.0.1:5584'` I go to the IP address on port 5584, but the web page is not available. Do I need to do something else first? And thank you for the link. I am writing the problem solver from there. – Michael Sherman Nov 24 '14 at 16:26
  • This is interesting post. I am experiencing rather similar problem; the app launches but it's not fully operational The `ui.R` is created as defined but there is no connection with the `server.R`, i.e. the app only functions as interface, without anything else. – Konrad Jul 06 '16 at 10:56
1

I've figured out my issue, mostly. The window still closes as soon as I launch the Shiny app, but now I can navigate to the Shiny app. This is good enough for me to consider this fixed.

There were two things I had to do. First, I had to open up the port that Shiny was listening on using GCE's command line, which was the second answer here, using the command line: How to open a specific port such as 9090 in Google Compute Engine

Then, I had to launch the Shiny app with the following command:

runExample("01_hello", host="0.0.0.0", port=9999)

This works with the runApp command as well. 9999 is the port number you open with GCE, and host=0.0.0.0 seems to tell Shiny to listen for external connections (from the in-R ?runApp help documentation). You need to literally put 0.0.0.0 in, not the IP of your machine or anything like that.

Even though the window closes still when I launch the example, I can how navigate to the external IP of the instance with the port number and use the Shiny app.

Thank you both for your assistance. Please feel free to comment if you think anything more should be said.

Community
  • 1
  • 1
Michael Sherman
  • 523
  • 2
  • 5
  • 16