0
votes

I am trying to write an Excel file using the Shiny app, on a Server. First step is just getting the package to load, I am using readXL as an example because a( its single line syntax and b) there are no unusual dependencies (looking at you Java).

First of all, my problem is having this run on a server, it runs on my Mac but not on any external server. I have tried Centos7, an EC2 running Ubuntu and an EC2 running Amazons Redhat based linux flavour. The problem seems to be allowing the Shiny server access (more on this later).

Here is some example code below. The .XLSX here is in my working directory. server.r

#library(openxlsx)
library(shiny)
library(readxl)
#library(abbyyR)
function(input, output) {

  a <- readxl::read_excel("test.xlsx")
  output$testXL <- renderTable(a)
}

ui.r

    fluidPage(

  titlePanel("Conditional panels"),

  column(4, tableOutput("testXL")
  )
)

In all cases, the conditional panel loads but not the data. If I run this app in R-Studio GUI and launch it using the local machine (tried all three) as a server, I can access it via the specified IP and Port (ie the below is accessible on x.x.x.x:5050.

>runApp(host="0.0.0.0",port=5050)

However placing this file in the server files (I've followed the standard setup - files under /srv/shiny-server/AppName) the server is disconnected. Taking out the readXL based code (inc loading the library) prevents a disconnect from server message.

I have tried openxlsx, XLSX and XLConnect, all fail when library(packageName) is included. The local directory has had RWX permissions applied to all user.

Any ideas?

1
Did you put the excel file in the same directory as the app?Gregor de Cillia
Yup. Tried removing all XL loading syntax as well, as soon as openxlsx, XLConnect or xlsx are included as packages (ie library(xlsxl)) the app fails. Perplexing!Ben

1 Answers

0
votes

Solved - some packages are writing to a folder (unsure why) which has permissions for the local user, and the R user, but not the Shiny user (which is how the app is accessed via Http). Find the file your packages are installed in using 'library()' and specify this as the libpath when installing the packages. You may also need to sudo chown/chgrp depending on your set up.