rdrop2 无法在 EC2 服务器上运行,但仍在本地主机和 shinyapps.io 上运行

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

我正在制作一个闪亮的应用程序,它应该从 Dropbox 下载一个 .html 文件并通过 htmlOutput() 在所述闪亮的应用程序中显示它。此外,我在 AWS EC2 t2.micro 实例上拥有它 运行(所有闪亮的服务器配置都基于 this article)。问题是我的应用程序在本地主机上运行,​​shinyapps.io;但是,它不适用于我的 EC2 实例。该应用程序在 Shiny Server 上运行(在 EC2 实例内)。

这里是源代码(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)

当应用程序在本地主机或 shinyapps.io 上运行时,应用程序会执行正确的操作并在 htmlOutput('viewFile') 上显示 html 文件。同时,它不适用于 EC2 实例。我在互联网上搜索了一些解决方案,但我尝试的任何一个都没有用。

如果有人知道导致此行为的原因,我将不胜感激!

注意:我注意到我的 EC2 实例在应用程序运行时不发送 XHR 请求(与 shinyapps.io 不同)

预期行为

我闪亮的应用程序(使用 rdrop2)应该在我的保管箱帐户中找到一个 .html 文件,下载它,然后能够使用 htmlOutput()

显示它

实际行为

找不到文件,它在 try()“文件不可用”

上显示错误

账户类型

Dropbox 基础版

我碰巧找到了解决我的问题的方法。这完全是 chmod(ing) www 文件夹的问题。这样,闪亮的用户就可以访问我的 .html 文件