dashR
dashR copied to clipboard
dash on RStudio server viewer pane not loading
Hello,
We have a private cloud and have been using Rstudio server (https://www.rstudio.com/products/rstudio/download-server/) for Shiny apps and all sorts. I am trying to build dash apps in it but it's stuck in the loading page for a long time. I wonder any of my settings is wrong. It runs fine on a desktop Rstudio.
my app:
library(dash)
library(dashCoreComponents)
library(dashHtmlComponents)
#https://support.rstudio.com/hc/en-us/articles/202133558-Extending-RStudio-with-the-Viewer-Pane
app <- Dash$new()
app$layout(
htmlDiv(
list(
htmlH1('Hello Dash'),
htmlDiv(children = "Dash: A web application framework for R."),
dccGraph(
figure=list(
data=list(
list(=list(1, 2, 3),y=list(4, 1, 2),type='bar',name='SF' ,
list(x=list(1, 2, 3),y=list(2, 4, 5),type='bar',name='Montr\U{00E9}al')),
layout = list(title='Dash Data Visualization')
)
)
)
)
)
app$run_server(use_viewer = TRUE)
When I run the app, the R terminal shows: Fire started at 127.0.0.1:8050 start: 127.0.0.1:8050 request: 127.0.0.1 - ID_127.0.0.1 [01/Apr/2021:13:35:51 +0000] "GET /?viewer_pane=1&capabilities=1&host=https%3A%2F%2Fxyz.ac.uk HTTP/1.1" 200 1796 "https://xyz.ac.uk/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36"
And on the Rstudio view pane, it just shows Loading... and not changing
Hi @cmtso thanks for opening this issue. The Loading... message you describe is unrelated to your code (there are a couple minor syntax issues in the snippet you posted, but they aren't the cause). I created a simple Dockerfile and was able to replicate the behaviour you describe:
Dockerfile
FROM rocker/rstudio
RUN apt-get update && apt-get install -y libxml2 libxml2-dev libcurl4-openssl-dev libv8-dev
COPY install_packages.sh /usr/local/bin/install_packages.sh
RUN chmod +x /usr/local/bin/install_packages.sh && \
/usr/local/bin/install_packages.sh
install_packages.sh
#!/usr/local/bin/Rscript
install.packages(c("remotes", "rstudioapi"))
remotes::install_github("plotly/dashR", ref="dev")
One possible explanation is that the paths to scripts and CSS are relative, and if you view the console log, you'll see that Dash tries to insert the URL and port for the host running RStudio Server (rather than your Dash app itself).
This is expected behaviour -- attempting to fetch the JS from the host on which the viewer pane is running -- but I can see how it would be confusing:

In this case I'm running the RStudio Server on localhost (127.0.0.1) via port 8787:

Dash is running on port 8050, but given the relative tags, it prepends the asset path with 127.0.0.1:8787 instead. The JavaScript bundles can't be found there, unfortunately, and so Dash is effectively stuck at the Loading... message.
We don't currently have this feature on our roadmap for Dash for R, but I'm grateful that you noted this behaviour! I'll leave the issue open in case circumstances change.