disconnected from server- local shiny server

Hello there

I having a sticky old question , I just took a project from someone left , there was an app running with shiny server , but now from days I see disconnected from server , I browsed the network trying to find a solution but was not able to find out, even by topics from here

I dont have updates on logs

the only thing I see , that rmarkdown package is installed but the default page [local-ip]:3838 is showing that box in the right still missing rmarkdown poackage , loading the app is giving disconnected from server ..

I dont know if something can help me find ouyt what ?

Thanks

You are not providing enough information for us to be able to help you. We need to see the app's logs to have an idea of what might be going on.

About shiny-server not being able to load rmarkdown files. This might be happening because rmarkdown is not installed system wide and the shiny user does not have access to it. You need to install R packages system wide in order for shiny apps to be able to use them.

Hello

I did installed it system wide with :
sudo su - -c "R -e "install.packages('rmarkdown', repos='http://cran.rstudio.com/')""

Also I am attaching photos for issue and setups...
Please tell me if there is any logs that I can share ?

rmarkdown-setup

shiny-R

Have you modified the run_as option in your shiny-server config file? Can you show the complete output of running sudo su - -c "R -e "install.packages('rmarkdown', repos='http://cran.rstudio.com/')"" in a system terminal?

BTW, please do not post screenshots of your terminal, they are considered a bad practice here, post the output as formatted code instead. Here is how to do it

Hi

The whole line command is giving a bash script error , so I install it with root user

*R version 3.6.3 (2020-02-29) -- "Holding the Windsock"*
*Copyright (C) 2020 The R Foundation for Statistical Computing*
*Platform: x86_64-pc-linux-gnu (64-bit)*

*R est un logiciel libre livré sans AUCUNE GARANTIE.*
*Vous pouvez le redistribuer sous certaines conditions.*
*Tapez 'license()' ou 'licence()' pour plus de détails.*

*R est un projet collaboratif avec de nombreux contributeurs.*
*Tapez 'contributors()' pour plus d'information et*
*'citation()' pour la façon de le citer dans les publications.*

*Tapez 'demo()' pour des démonstrations, 'help()' pour l'aide*
*en ligne ou 'help.start()' pour obtenir l'aide au format HTML.*
*Tapez 'q()' pour quitter R.*

*[Sauvegarde de la session précédente restaurée]*

*> install.packages("rmarkdown")*
*Installation du package dans ‘/usr/local/lib/R/site-library’*
*(car ‘lib’ n'est pas spĂ©cifiĂ©)*
*essai de l'URL 'https://cloud.r-project.org/src/contrib/rmarkdown_2.19.tar.gz'*
*Content type 'application/x-gzip' length 3243575 bytes (3.1 MB)*
*==================================================*
*downloaded 3.1 MB*

** installing *source* package ‘rmarkdown’ ...*
*** package ‘rmarkdown’ correctement dĂ©compressĂ© et sommes MD5 vĂ©rifiĂ©es*
*** using staged installation*
*** R*
*** inst*
*** byte-compile and prepare package for lazy loading*
*** help*
**** installing help indices*
**** copying figures*
*** building package indices*
*** installing vignettes*
*** testing if installed package can be loaded from temporary location*
*** testing if installed package can be loaded from final location*
*** testing if installed package keeps a record of temporary installation path*
** DONE (rmarkdown)*

*Les packages source téléchargés sont dans*
*        ‘/tmp/RtmpgIFHFK/downloaded_packages’*
*>*

for the user from file /etc/shiny-server/shiny-server.conf
run_as shiny;

It might be a permissions issue with the site-library folder, just to test my theory can you set the folder permissions to 777 just for a quick test?

sudo chmod 777 -r /usr/lib/R/site-library

Another possibility is that for some reason the .libPaths() of the shiny user are pointing to a different location but I can't think of an easy way to test that other than printing the .libPaths() in your app itself.

I just tried .... it is annoying as nothing came up ... getting same result

Also , using shiny user , I am able to find the library rmarkdown
and

.libPaths()
[1] "/home/shiny/R/x86_64-pc-linux-gnu-library/3.6"
[2] "/usr/local/lib/R/site-library"
[3] "/usr/lib/R/site-library"
[4] "/usr/lib/R/library"

I thought it was not possible to log as the shiny user, my bad.

Sorry, I'm out of ideas. I can't think of a reason for shiny-server not recognizing rmarkdown.

If not , can you please think about how can I troubleshoot why an app is giving disconnected from server ?

That is a generic message you get on the app client when the app crashes on the server, we would need to see the logs to have a clue of what is going on. Each app generates a log file in the /var/log/shiny-server/ folder when the app is running, if the app crashes, the file is kept.

Here are the last 2 logs from the APP by 5 January

==> /var/log/shiny-server/APP-shiny-20230105-104133-33049.log <==
closing unused RODBC handle 7
Warning in for (name in names(public_methods)) lockBinding(name, public_bind_env) :
closing unused RODBC handle 6
Warning in for (name in names(public_methods)) lockBinding(name, public_bind_env) :
closing unused RODBC handle 5
Warning in for (name in names(public_methods)) lockBinding(name, public_bind_env) :
closing unused RODBC handle 4

ExĂ©cution arrĂȘtĂ©e

==> /var/log/shiny-server/APP-shiny-20230105-123237-43355.log <==
les noms de lignes sont trouvés dans une variable courte et ont été éliminés
Warning in for (i in seq_along(cenv$extra)) { :
closing unused RODBC handle 1

ExĂ©cution arrĂȘtĂ©e
Warning messages:
1: closing unused RODBC handle 3
2: closing unused RODBC handle 2

Those logs are not very informative, I don't see an evident reason. I would explore the possibility that your RDBMS or some network security feature in your server might be closing the connection on its side.

I don't have experience debugging shiny apps on the client side but if you know your way around HTML and Javascript you could inspect the console on the client's browser to get more information.

If you can run the app interactively from RStudio you could also try to debug following this guideline

1 Like

hello Andres

I have some few updates if you can assume something

I had upgraded R to latest 4.2 and shiny server too
I have them working with no issues and also on the sample default page everything is working even that part which require markdown package installed

but the app still not loading
trying to excute server.R giving
shiny@bims:/srv/shiny-server/APP$ ./server.R
./server.R: ligne 4: erreur de syntaxe prÚs du symbole inattendu « XML »
./server.R: ligne 4: `require(XML)'

running R and checking XML and other required packages shiwing that they exist ... can you wonder if there is a mistake here ? do I change packages path to another shared location ? knowing that I tryed with chmod 777 at /usr/lib/R...

This is not meant to be executed from the terminal but the syntax warning makes me think on a possible encoding issue, are you able to share a link to your app files so I can take a look?

Here is a folder with app files

https://drive.google.com/drive/folders/1GU5TdF11sHr-kZlNXoU0RouBcKXXYG5n?usp=share_link

Encoding seems to be OK but the library calls are a mess, there are a bunch of duplicated and commented library calls in both app files, and maybe that is causing the problem. I would start by tidying up the library calls and avoid using require(), use library() instead.

1 Like

This topic was automatically closed 54 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.