Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot open multiple RShiny App simulatenously #481

Open
dylancis opened this issue Mar 8, 2024 · 10 comments
Open

Cannot open multiple RShiny App simulatenously #481

dylancis opened this issue Mar 8, 2024 · 10 comments
Labels

Comments

@dylancis
Copy link

dylancis commented Mar 8, 2024

Hi @tverbeke -
Since the upgrade to 3.0.2 I cannot open multiple same RShiny app in multipe tabs which I always used to do that (even though the R kernel could only run one thread at the time). I don't have the issue with Dash app, I can open as many as I want.

The behaviour is that when I open a second tab using RShiny, the first one already opened stopped:
image
And the console shows:
image

Can you please tell me if there was something change in that newer version that is causing that?

@LEDfan
Copy link
Member

LEDfan commented Mar 11, 2024

Hi @dylancis

This should still be possible in version 3.0.2. Which version were you using previously?
The error message indicates that the websocket connection was closed, this could be caused because the Shiny app runs into an error. Can you check the logs/output of the shiny app? In addition can you also check and post the ShinyProxy logs?

@LEDfan LEDfan added the bug label Mar 11, 2024
@dylancis
Copy link
Author

Thanks @LEDfan , this was indeed my undersatanding as per our conversation here: #397

Before we were using 2.6.1, we have 3 apps in Dash hosted in ShinyProxy and 3 RShiny, the 3 RShiny app have now the same issue. The app-logs do not contains anything once the app shut down - which makes me believe this is coming from ShinyProxy itself. Note that configuration of the app (YAML) has not changed following the upgrade.

It seems somehow related to this one https://support.openanalytics.eu/t/unexpected-and-unpredictable-shiny-app-terminations-with-shinyproxy/2661

Please find attached the log of Shinyproxy where you can the error UT001000
logs-insights-results.json

@LEDfan
Copy link
Member

LEDfan commented Mar 11, 2024

Since you are only having the issue with Shiny apps and the issue is caused by an asset failing to load, I suspect that you are experiencing the issue described here: https://shinyproxy.io/faq/#the-assets-of-my-shiny-app-sometimes-fail-to-load-http-error-503

Can you try installing Shiny using the above method? Please make sure to not have any other command in your Dockerfile that install shiny (e.g. if you currently have install.packages('shiny') somewhere, you need to remove that line.

@dylancis
Copy link
Author

Thanks for your suggestion @LEDfan . However I don't think this is related to that.

We have reverted back to 2.6.1 today - using the same app and the same R-base image, only ShinyProxy jar version changed and the issue is now gone in 2.6.1.

@dylancis
Copy link
Author

dylancis commented Mar 19, 2024

Since you are only having the issue with Shiny apps and the issue is caused by an asset failing to load, I suspect that you are experiencing the issue described here: https://shinyproxy.io/faq/#the-assets-of-my-shiny-app-sometimes-fail-to-load-http-error-503

Can you try installing Shiny using the above method? Please make sure to not have any other command in your Dockerfile that install shiny (e.g. if you currently have install.packages('shiny') somewhere, you need to remove that line.

@LEDfan I did what you suggested, please find below the Dockerfile, and the issue remains. 2.6.1 is still working fine though.

FROM ubuntu:18.04

ENV DEBIAN_FRONTEND noninteractive
ENV PYTHONIOENCODING utf-8
ENV LANG en_US.UTF-8
ENV R_BASE_VERSION 4.3.1


RUN \
  # Upgrade packages
  apt-get update && \
  apt-get -y upgrade && \
  apt-get -y clean && \
  rm -rf /tmp/* /var/tmp/* && \
  rm -rf /var/lib/apt/lists/*
  
RUN \
  # Add ubuntu user
  groupadd -g 12574 ubuntu && \
  useradd -u 12574 -g 12574 -m -N -s /bin/bash ubuntu && \
  chown -R ubuntu:ubuntu /home/ubuntu

RUN \
  # Configure locales
  apt-get update && \
  apt-get -y --no-install-recommends install locales ed less wget ca-certificates apt-transport-https gsfonts curl apt-utils git p7zip-full dirmngr sudo libv8-dev openjdk-8-jdk gpg gpg-agent && \
  locale-gen en_US.UTF-8 && \
  dpkg-reconfigure locales && \
  apt-get -y clean && \
  rm -rf /tmp/* /var/tmp/* && \
  rm -rf /var/lib/apt/lists/*

RUN \
  # INSTALL Python 3, R and R packages
  echo "deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran40/" > /etc/apt/sources.list.d/r.list && \
  gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 && \
  gpg -a --export E298A3A825C0D65DFD57CBB651716619E084DAB9 | sudo apt-key add - && \
  wget -qO- https://cloud.r-project.org/bin/linux/ubuntu/marutter_pubkey.asc | sudo gpg --dearmor -o /usr/share/keyrings/r-project.gpg && \
  #echo "deb [signed-by=/usr/share/keyrings/r-project.gpg] https://cloud.r-project.org/bin/linux/ubuntu jammy-cran40/" | sudo tee -a /etc/apt/sources.list.d/r-project.list && \
  apt-get update && \
  apt-get -y --no-install-recommends install python3 python3-pip python3-wheel python3-setuptools python3-dev libssl-dev libxml2-dev libxt-dev libssh2-1-dev libcurl4-openssl-dev  libfontconfig1-dev libharfbuzz-dev libfribidi-dev libfreetype6-dev libpng-dev libtiff5-dev libjpeg-dev libpcre2-dev r-base=${R_BASE_VERSION}* r-base-dev=${R_BASE_VERSION}* r-recommended=${R_BASE_VERSION}* pandoc libglpk-dev
RUN \
  chown -R ubuntu:ubuntu /home/ubuntu && chown -R ubuntu:ubuntu /usr/local/lib/R/site-library && \
  apt-get clean && \
  rm -rf /tmp/* /var/tmp/* && \
  rm -rf /var/lib/apt/lists/*
  
RUN \
  # Make Python 3 default
  mkdir /usr/local/python-defaults && \
  ln -s /usr/bin/python3 /usr/local/python-defaults/python && \
  ln -s /usr/bin/pip3 /usr/local/python-defaults/pip && \
  #
  # Ensure the non-root pip destination directory exists.
  # If it exists before python is started, it will be automatically added to the import path.
  # If it does not exist before python is started, it will not be added to the import path.
  # If you try to get around this by manually adding it to the PYTHONPATH but not creating
  # the directory, if any code does an import, python will see that the directory does not exist,
  # and IGNORE it for all future imports, even if the directory is later created.
  # Get the directory created by installing a small package with no dependencies to the non-root install location.
  # We can't remove the package because pip then removes the whole .local directory.
  # The directory is /home/ubuntu/.local/lib/python3.6/site-packages, but that can change
  # with different python versions, so actually installing a package is a good way to ensure it exists.
  su -l -c "pip3 --no-cache-dir install appdirs" ubuntu && \
  # Add our symlinked python and pip to the PATH, and also add the user local bin directory,
  # where non-root pip installed programs get installed to, to the PATH.
  export PATH=/usr/local/python-defaults:/home/ubuntu/.local/bin:${PATH:-}

COPY dbrs.local.crt /usr/local/share/ca-certificates/dbrs.local.crt
RUN update-ca-certificates
RUN git config --global http.sslverify false

# Install additional Python 3 libraries.
# Install dbrs-domino and dbrs-insight manually. Check the requirements.txt file in dbrs-analytics-client-py repo.
# Tries to find the other dbrs packages on pypi instead of installing from git.
# Two dbrs-analytics-client-py urls are provided: GSFA is for internal, EU-External is for external
RUN \
  pip3 --no-cache-dir install jsonpickle && \
  pip3 --no-cache-dir install git+http://github.dbrs.local/GSFA/dbrs-domino-py@master-release-0.3.8-622343d#egg=dbrs-domino && \
  pip3 --no-cache-dir install git+http://github.dbrs.local/GSFA/dbrs-insight-py@master-release-0.4.16-f27f53f#egg=dbrs-insight && \
  pip3 --no-cache-dir install --trusted-host github.dbrs.local git+http://github.dbrs.local/GSFA/dbrs-analytics-client-py@master-release-0.2.22-7d4760a#egg=dbrs-analytics-client && \
  pip3 --no-cache-dir install --trusted-host github.dbrs.local git+http://github.dbrs.local/EU-External/dbrs-analytics-client-external-py.git@master-release-0.0.5#dbrs-analytics-client-external && \
  pip3 --no-cache-dir install --trusted-host github.dbrs.local git+http://github.dbrs.local/GSFA/dbrs-analytics-client-py@master-release-0.2.27-b09900f && \
  pip3 --no-cache-dir install boto3==1.18.10 
# #set R for java right and install packages
RUN \
  R CMD javareconf && \
  R -e 'options(repos=structure(c(CRAN="http://cran.us.r-project.org"))); update.packages(ask = FALSE)'
RUN \
  R -e 'install.packages("devtools", Ncpus = 16)'
RUN \
  R -e 'install.packages(c("remotes","utils","parallel","tools","memoise","ellipsis","urlchecker"))'
RUN \   	
  R -e 'devtools::install_version("data.tree","1.0.0")'
RUN \   	
  R -e 'devtools::install_version("aws.s3", "0.3.20")'
RUN \   	
  R -e 'devtools::install_version("shinyjs","1.0")'
RUN \   	
  R -e 'devtools::install_version("base64enc", "0.1-3")'
RUN \   	
  R -e 'devtools::install_version("formattable","0.2.1")'
RUN \   	
  R -e 'devtools::install_version("future","1.32.0")'
RUN \   	
  R -e 'devtools::install_version("htmlTable","1.13.1")'
RUN \   	
  R -e 'devtools::install_version("httr","1.4.7")'
RUN \   	
 R -e 'devtools::install_version("logging","0.10-108")'
RUN \   	
  R -e 'devtools::install_version("openxlsx","4.1.0")'
RUN \   	
  R -e 'devtools::install_version("readr","2.1.4")'
RUN \   	
  R -e 'devtools::install_version("rhandsontable","0.3.7")'
RUN \   	
  R -e 'devtools::install_version("rpivotTable","0.3.0")'
RUN \   	
  R -e 'devtools::install_version("shinyBS","0.61")'
RUN \   	
  R -e 'devtools::install_version("shinydashboard","0.7.2")'
RUN \   	
 R -e 'devtools::install_version("snakecase","0.11.0")'
RUN \   	
  R -e 'devtools::install_version("sparkline","2.0")'
RUN \   	
  R -e 'devtools::install_version("stringr","1.5.0")'
RUN \   	
  R -e 'devtools::install_version("uuid","1.1-0")'
RUN \   	
  R -e 'devtools::install_version("V8","4.3.0")'
RUN \   	
  R -e 'devtools::install_version("varhandle","2.0.5")'
RUN \   	
  R -e 'devtools::install_version("xml2","1.3.3")'
RUN \   	
  R -e 'devtools::install_version("yaml","2.3.7")'
RUN \   	
  R -e 'devtools::install_github("hrbrmstr/roto.athena")'
RUN \
  R -e 'remotes::install_github("bnosac/GAlogger")'
RUN \
  R -e 'devtools::install_github(c("ijlyttle/bsplus", "rstudio/DT@v0.7", "jbkunst/highcharter", "sbihorel/rclipboard", "rstudio/shiny-incubator", "AnalytixWare/ShinySky", "dreamRs/shinyWidgets", "burgerga/htmltab"))'
RUN \
  R -e 'devtools::install_github("GSFA/dbrs-analytics-client-r@v0.0.2", host="http://github.dbrs.local/api/v3")'
RUN \
  R -e 'devtools::install_github("GSFA/shiny-css-loader@0.2.3", host="http://github.dbrs.local/api/v3")'
RUN \
  R -e 'devtools::install_github("EU-External/dbrs-analytics-client-external-r@v0.0.3", host="http://github.dbrs.local/api/v3")'
RUN \
  R -e 'devtools::install_version("RJDBC", "0.2-7.1")'
  # AWR.Athena downloads the latest version of RJDBC and DBI
RUN \ 	
  R -e 'devtools::install_version("AWR.Athena", "1.1.0-1", upgrade="never")'
RUN \   	
  R -e 'install.packages("shinydisconnect")'
RUN \   	
  R -e 'devtools::install_version("DBI","1.0.0")'
RUN \   	
  R -e 'devtools::install_version("rclipboard", "0.1.1")'
RUN \   	
  R -e 'devtools::install_version("rJava","0.9.13")'
RUN \   	
  R -e 'devtools::install_version("htmltab","0.7.1")'
RUN \   	
  R -e 'devtools::install_version("highcharter","0.9.4")'
RUN \   	
  R -e 'devtools::install_version("jsonlite","1.7.3")'
RUN \
   R -e 'devtools::install_version("withr", "3.0.0")' 
# RUN \   	
#   R -e 'devtools::install_version("shiny", "1.6.0")'
RUN \
  R -e "withr::with_makevars(c(PKG_CPPFLAGS='-DHTTP_MAX_HEADER_SIZE=0x7fffffff'), {devtools::install_version('shiny', '1.6.0')}, assignment = '+=')"
RUN \   	
  R -e 'devtools::install_version("curl", "5.1.0")'
RUN \	 
  chown -R ubuntu:ubuntu /usr/local/lib/R/site-library && \
  rm -rf /tmp/* /var/tmp/*

@dylancis
Copy link
Author

dylancis commented Apr 4, 2024

I noticed that while in 2.6.1 the ShinySession returned the url as

http://shiny-dev.cr0a68f.easn.morningstar.com/app_direct_i/eurmbsinsight

The 3.0.2 version returns is differenty:

http://shiny-prod.crcc2f9.eas.morningstar.com/app_proxy/3293fede-ab92-4b5b-8a08-5df4722fd622

Could that be the reason?

@dylancis
Copy link
Author

dylancis commented May 7, 2024

Hi @LEDfan should I try with 3.1.0 version see if the issue for resolved ? Thanks

@LEDfan
Copy link
Member

LEDfan commented May 7, 2024

Hi @dylancis unfortunately, I was not able to re-produce your issue, so the release does not include a fix specific to this issue. However, it contains various improvements, that might solve this issue, so it would be good to try it out and know whether it's fixed.

@LEDfan
Copy link
Member

LEDfan commented May 14, 2024

Hi @dylancis I continued looking into this and found a potential fix. Could you please try using image openanalytics/shinyproxy-snapshot:3.1.0-20240514.165349 and let us know whether this fixes the issue for you?

Note that you might still see some exceptions being logged:

2024-05-14T15:01:41.337Z ERROR 1 --- [   XNIO-1 I/O-3] io.undertow.proxy                        : UT005028: Proxy request to /proxy_endpoint/59db457b-19f3-47e6-8184-05cc519fd470/shared/shiny-showcase.js failed

java.io.IOException: UT001000: Connection closed
	at io.undertow.client.http.HttpClientConnection$ClientReadListener.handleEvent(HttpClientConnection.java:600) ~[undertow-core-2.3.10.Final.jar!/:2.3.10.Final]
	at io.undertow.client.http.HttpClientConnection$ClientReadListener.handleEvent(HttpClientConnection.java:535) ~[undertow-core-2.3.10.Final.jar!/:2.3.10.Final]
	at org.xnio.ChannelListeners.invokeChannelListener(ChannelListeners.java:92) ~[xnio-api-3.8.8.Final.jar!/:3.8.8.Final]
	at org.xnio.conduits.ReadReadyHandler$ChannelListenerHandler.readReady(ReadReadyHandler.java:66) ~[xnio-api-3.8.8.Final.jar!/:3.8.8.Final]
	at org.xnio.nio.NioSocketConduit.handleReady(NioSocketConduit.java:89) ~[xnio-nio-3.8.8.Final.jar!/:3.8.8.Final]
	at org.xnio.nio.WorkerThread.run(WorkerThread.java:591) ~[xnio-nio-3.8.8.Final.jar!/:3.8.8.Final]

But this does not seem to cause an actual issue. If this fixes the error, I'll look into preventing the exceptions.

@dylancis
Copy link
Author

thanks @LEDfan , will test for sure and revrt to you here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants