Error under Shiny Server that doesn't appear in RStudio

I have a shiny application which is running fine on the browser, and is generating errors when I put it on my server (pluto.coe.fsu.edu/rdemos).

Here is the core part of the code:

inputPanel(
  selectInput("tails1", label = "Which tails",
              choices = c("Upper tail: Pr(z < Z)"="upper",
                          "Lower tail: Pr(Z < z)"="lower",
                          "Both tails: Pr(Z <-z or z< Z)"="both",
                          "Middle: Pr(-z < Z < z)"="middle"),
              selected = "both"),
  
  numericInput("p", label = "Probability of shaded region:", value=0.05, min=0, max=1)
)

renderPlot({
  pp <- input$p
  q <- switch(input$tails1,
              upper=qnorm(1-pp),
              lower=qnorm(pp),
              both=qnorm(1-pp/2),
              middle=qnorm(.5+pp/2))
  xl <- round(max(3,ceiling(abs(q)+.5)),1)
  curve(dnorm(x),main=paste("Probability of shaded region = ",round(pp,3)),
        sub=paste("z = ",round(q,3)),
        xlim = c(-xl,xl),yaxt="n",cex=3,cex.lab=2,cex.main=2,ylab="",xlab="z")
})

This works on my desktop in RStudio (Running R 4.3.2 and shiny 1.8.0), but is generating an error when running on the server (also running R 4.3.2 and shiny 1.8.0).

On the sever, the relevant parts of the log file are:

Output created: /tmp/RtmpFeD6p9/file1ba53c5289ea58/NormalCalculator.html
Warning: Error in switch: EXPR must be a length 1 vector
  170: renderPlot [<text>#14]
  168: func
  128: drawPlot
  114: <reactive:plotObj>
   98: drawReactive
   85: renderFunc
   84: output$out7f5ebc68b3bd0d95
    3: <Anonymous>
    1: rmarkdown::run

The issue seems to be that the initial return value for the input from the selectInput() widget is not the value of the selected argument, quite possibly NULL In particular, if I edit the renderPlot() function to include a specific NULL check, it works on the server:

  mde <- input$tails
  if (length(mde) != 1L) mde <- "both"
  p <- switch(mde,

So something is not getting initialized properly on my shiny server.

Okay, I got smart and looked at the difference between the version from the shiny server and the RStudio version.

The remote version has this as its header:

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <script type="application/shiny-singletons"></script>
  <script type="application/html-dependencies">jquery[3.6.0];shiny-css[1.8.0];shiny-javascript[1.8.0]</script>
<script src="jquery-3.6.0/jquery.min.js"></script>
<link href="shiny-css-1.8.0/shiny.min.css" rel="stylesheet" />
<script src="shiny-javascript-1.8.0/shiny.min.js"></script>  <script src="rmd_resources/rmd_loader.js"></script>
  <link href="rmd_resources/rmd_loader.css" rel="stylesheet"/>
</head>

While the RStudio version has these additional lines at the bottom of the head session:

<script src="__assets__/sockjs.min.js"></script>
<script src="__assets__/shiny-server-client.min.js"></script>
<script>preShinyInit({reconnect:true,disableProtocols:[]});</script>
<link rel="stylesheet" type="text/css" href="__assets__/shiny-server.css"/>

So the question is why does my shiny server instance not include those lines? Also, why did this change from working to not working on the server?

I'm Running Shiny Server 1.5.21 on RHEL 8.6. Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k mod_fcgid/2.3.9 SVN/1.10.2 mod_wsgi/4.6.4 Python/3.6 mod_apreq2-20101207/2.8.1

I'm running the shiny server through a proxy that maps subdomain URLs to the shiny server.

As this is RHEL, there may be a SELinux permission issue related to the assets, not sure where to look there.

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.