rdrop2 not working on EC2 server, but still working on localhost and shinyapps.io

Hello,

I am making a shiny app that should download a .html file from dropbox and show it in said shiny app via a htmlOutput(). Furthermore, I have it running on a AWS EC2 t2.micro instance (with all the shiny server configurations based on this article). The problem is that my app works on localhost, shinyapps; but, it does not work on my EC2 instance.

Here is the source code (app.R):

library(shiny)
library(rdrop2)
library(httr)

# token <- drop_auth()
# saveRDS(token, "droptoken.rds")
# Upload droptoken to your server
# ******** WARNING ********
# Losing this file will give anyone 
# complete control of your Dropbox account
# You can then revoke the rdrop2 app from your
# dropbox account and start over.
# ******** WARNING ********
# read it back with readRDS
token <- readRDS("droptoken.rds")
# Then pass the token to each drop_ function
drop_acc(dtoken = token)

ui <- fluidPage(
  h1("rdrop2 practice"),
  htmlOutput("viewFile")
)

server <- shinyServer(function(input, output, session) {

  directoryPath <- paste0("path1/", "path2/")
  
  fileName <- "file.html"
  
  filePath <- paste0(directoryPath, fileName)

  # Download File
  filePut <-
    try({
      withProgress(message = "Generating File",
                   detail = "This may take few seconds depending of your Internet connection",
                   drop_download(path = filePath,
                                 local_path = "./www",
                                 overwrite = TRUE,
                                 dtoken = token)
      )
      
      fileName
    }, silent = TRUE)

  # Show File
  output$viewFile <- renderUI({
    
    validate(
      need(filePut, 'File Not Available')
    )
    
    tags$div(class="resp-container")
    
    tags$iframe(class="resp-iframe",
                seamless = "seamless",
                src = filePut)
  })
})


shinyApp(ui, server)

When the app runs on localhost or shinyapps.io, the app does the proper thing and shows the html file on the htmlOutput('viewFile'). Meanwhile, it does not work on the EC2 instance. I searched all over the internet for some solution, but nothing I try works.

If somebody has some idea on what is causing this behavior, I will appreciate the help !

Note: I noticed that my EC2 instance does not send XHR requests during the app runtime (unlike in shinyapps)

I had this old post ready to share a long while ago, but I could not share it due to new account creation.

At the end of the day, I fixed the issue. The problem was that I had to enable some file permissions to the www folder server side (using chmod).

This topic was automatically closed 7 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.