R Shiny dev on RStudio server Shiny crashes when app launch

4.9k views Asked by At

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)}

3

There are 3 answers

0
Michael Sherman On BEST ANSWER

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.

2
Mikael Jumppanen On

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.

0
guest On

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/