0

My question is : How this Shiny R code mini web server in JupyterHub could work outside this server (i.e. <> localhost) ?

ui <- fluidPage(
    textInput("caption", "Caption", "Data Summary"),
    verbatimTextOutput("value")
)

server <- function(input, output) {
    output$value <- renderText({ input$caption })
}

shinyApp(ui, server)
Listening on http://127.0.0.1:4844

It works on the local server (127.0.0.1:4844) , but I doesn't work on http://192.168.x.x:4844

For information. I've installed Jupyter and Jupyter Hub, with R Kernel, on Ubuntu 16.04 xenial. I've also installed Shiny Server and RStudio Server. Everything works fine. My firewall is off and I have Apache2.

I've seen this error on an other mini web server called from Jupyterhub in other mean that Shiny. The same code works in Rstudio Server IDE.

The problem is in the configuration of Jupyter Hub or Shiny Server or in Apache 2 or elsewhere ?

"You are using Jupyter notebook. The version of the notebook server is: 5.4.0 The server is running on this version of Python: Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 18:10:19) [GCC 7.2.0])".

Thanks in advance.

phili_b
  • 885
  • 9
  • 27
  • 1
    I don't know about the Jupyter Hub thing. But to make the Shiny app accessible from other machines, have you tried setting the `shiny.host` option to `"0.0.0.0"`? Also see https://shiny.rstudio.com/reference/shiny/latest/runApp.html – greg L Dec 03 '18 at 00:36
  • yes it's that, thanks :) In fact it was yet used where I work. I didn't make the link between this and Jupyter Hub. (Use Answer if you want the bounties). – phili_b Dec 03 '18 at 08:30

2 Answers2

0

From @greg L comment. With ShinyApp() wrapped in RunApp() with host="0.0.0.0".

ui <- fluidPage(
    textInput("caption", "Caption", "Data Summary"),
    verbatimTextOutput("value")
)

server <- function(input, output) {
    output$value <- renderText({ input$caption })
}

runApp(shinyApp(ui, server),host = "0.0.0.0")

gave

Listening on http://0.0.0.0:6596

With http://192.168.x.x:my_port

  • 192.168.x.x : the Shiny Server host
  • my_port: the port given at the launch
phili_b
  • 885
  • 9
  • 27
  • I tried to run with http://0.0.0.0:5057. It gets open with http://127.0.0.1:5057. How another person can visit this dashboard on another machine? – Sanky Ach Jan 02 '19 at 07:57
  • The other person have to type the IP of the server. For example http://192.168.3.4:5057 if the server ip is 192.168.3.4 – phili_b Jan 03 '19 at 10:19
0

Shiny apps listen on 127.0.0.1 (localhost) by default, which only the local machine can access. To make an app accessible to other machines, you can set the host option to 0.0.0.0:

options(shiny.host = "0.0.0.0")

or

runApp(host = "0.0.0.0")

See https://shiny.rstudio.com/reference/shiny/latest/runApp.html for more details.

greg L
  • 4,034
  • 1
  • 19
  • 18