Problems with dropbox file download within shiny.io

539 views
Skip to first unread message

f.e.bussma...@googlemail.com

unread,
Aug 28, 2016, 12:35:36 PM8/28/16
to shinyapps.io Users
Dear collegues,
I have set up a shiny webpage with data which should be renewed every night. The program structure is almost similar to the post of Jean-Pierre Gattuso earlier.
 For this I send a new datafile every night to my dropbox account and now I try to convince my app to download this file, however with no success so far. The app runs perfect on my computer incl. data download from Dropbox but refuses to do the data download as soon as I publish the app to shini.io.


In the logfile from my shiny account if get:
2016-08-28T12:14:45.657018+00:00 shinyapps[120758]: in Dropbox
2016-08-28T12:14:45.663051+00:00 shinyapps[120758]: 7: connect$retry
2016-08-28T12:14:45.663218+00:00 shinyapps[120758]: Error in gzfile(file, "rb") : kann Verbindung nicht öffnen
2016-08-28T12:14:45.657421+00:00 shinyapps[120758]: Warnung in gzfile(file, "rb")
2016-08-28T12:14:45.663049+00:00 shinyapps[120758]: 11: doTryCatch
2016-08-28T12:14:45.657423+00:00 shinyapps[120758]: kann komprimierte Datei 'droptoken.rds' nicht öffnen. Grund evtl. 'No such file or directory' -> cannot open compressed file 'droptoken.rds'. Possibly "No such file or directory"
2016-08-28T12:14:45.663051+00:00 shinyapps[120758]: 8: tryCatch
2016-08-28T12:14:45.658137+00:00 shinyapps[120758]: Warnung: Error in gzfile: kann Verbindung nicht öffnen
2016-08-28T12:14:45.663050+00:00 shinyapps[120758]: 9: tryCatchList
2016-08-28T12:14:45.663054+00:00 shinyapps[120758]: 1: local
2016-08-28T12:14:45.663045+00:00 shinyapps[120758]: Stack trace (innermost first):
2016-08-28T12:14:45.663052+00:00 shinyapps[120758]: 5: eval
2016-08-28T12:14:45.663047+00:00 shinyapps[120758]: 54: gzfile+
2016-08-28T12:14:45.663052+00:00 shinyapps[120758]: 6: eval
2016-08-28T12:14:45.663047+00:00 shinyapps[120758]: 53: readRDS
2016-08-28T12:14:45.663050+00:00 shinyapps[120758]: 10: tryCatchOne
2016-08-28T12:14:45.663054+00:00 shinyapps[120758]: 2: eval.parent
2016-08-28T12:14:45.663048+00:00 shinyapps[120758]: 52: server [/srv/connect/apps/svl_ferrybox/app.R#53]
2016-08-28T12:14:45.663053+00:00 shinyapps[120758]: 4: eval
2016-08-28T12:14:45.663048+00:00 shinyapps[120758]: 13: runApp
2016-08-28T12:14:45.663049+00:00 shinyapps[120758]: 12: fn
2016-08-28T12:14:45.663053+00:00 shinyapps[120758]: 3: eval

The code to read the file is:

server <- function(input, output) {
  message("in Dropbox")
  token <- readRDS("droptoken.rds")
  drop_acc(dtoken = token)
  drop_get("svl_ferrybox_all_select.avg.hour.csv", overwrite = TRUE)
  svl_ferrybox_all_select.avg.hour <- read.csv("svl_ferrybox_all_select.avg.hour.csv", header=TRUE)
  
    svl_ferrybox_all_select.avg.hour$datetime = strptime(svl_ferrybox_all_select.avg.hour$datetime,"%Y-%m-%d %H:%M:%S")
    svl_ferrybox_all_select.avg.hour$datetime <-as.POSIXct(svl_ferrybox_all_select.avg.hour$datetime)
    svl_ferrybox_all_select.avg.hour$date <- as.Date(svl_ferrybox_all_select.avg.hour$date)
  

  data.r <- reactive({
    a = dplyr::filter(svl_ferrybox_all_select.avg.hour, date > input$dateRange[1] &
                        date < input$dateRange[2])
    return(a)
  }
  )
........

So the log says that there is possibly no droptoken.rds on the server??
Can anybody help how to put this file to the place where it is needed?

I tried all recommendations I found in the internet with no success.


Thanks a lot in advance?

Philipp




  






Joshua Spiewak

unread,
Aug 29, 2016, 5:13:42 PM8/29/16
to shinyapps.io Users
Have you placed the droptoken.rds next to your server.R and ui.R files?
What recommendations have you tried and in what ways have they not worked?

Philipp Fischer

unread,
Oct 8, 2016, 4:41:10 AM10/8/16
to shinyapps.io Users
I have uploaded the droptoken.rds file with the app to the shiny server so it should be there.
And I tried to follow all instructions given in http://stackoverflow.com/questions/33177033/shinyapp-dropbox-authentication-with-rdrop2
Thanks a lot for the help.
Philipp

Philipp Fischer

unread,
Oct 8, 2016, 1:55:18 PM10/8/16
to shinyapps.io Users
Dear collegues,
I now tried another way to automatically deploy my app but also failed. I do not know what is wrong here because normally my apps are working quite well. I now tried to deploy the app via console completely so that I can deploy the entire app every night to update the daily files.

Again the app is perferctly to deploy from R Studio but not from the console. I tried all possible ways (including a simple app from the net) but always get the same error when I try to deploy the app by a batchfile via the console:

Preparing to deploy document...DONE
Uploading bundle for document: 130102...
Load package: rsconnect
Error in contrib.url(repos, type) :
  trying to use CRAN without setting a mirror
Calling: deployApp ... withCallingHandlers -> <Anonymous> -> available.packages -> contrib.url
Execution stopped.

The web say quite clearly that in the case of deployment via the console the packages have to installed separately and the repository has to be named what I did.
My code (deploy_test.R) for deployment which I call from a batchfile ("C:\Program Files\R\R-3.3.1\bin\Rscript.exe" "C:\AABackup\Shiny\code\deploy_test.R") is:

setwd("C:/AABackup/Shiny/code/test") #the app is in that directory
install.packages("shiny", repos="https://cran.rstudio.com/")
library(shiny)
install.packages("rsconnect", repos="https://cran.rstudio.com/")
library(rsconnect)

rsconnect::setAccountInfo(name='cosyna-nodes', token='431669DA29#######', secret='Qf32ulpnqTOe########')

deployApp(appDir = getwd(), appFiles = NULL, appFileManifest = NULL,
          appPrimaryDoc = "test.R", appSourceDoc = NULL, appName = NULL,
          contentCategory = NULL, account = NULL, server = NULL, upload = TRUE,
          launch.browser = getOption("rsconnect.launch.browser", interactive()),
          quiet = FALSE, lint = TRUE, metadata = list())

As said, it works perfectly from RStudio but not when I call this code from the console via a batchfile.

Philipp Fischer

unread,
Oct 9, 2016, 3:46:02 AM10/9/16
to shinyapps.io Users
I have solved the problem:

The below error message can be avoided when putting the line

chooseCRANmirror(ind = ###,useHTTPS = getOption("useHTTPS", TRUE), local.only = TRUE)

before the deployApp line.

the value for ind = ### can be chosen in the local cran list on the respective computer where R is running. This file is in the folder C:\Program Files\R\R-3.3.1\doc and is named CRAN_mirrors.csv. The value for ind is the line number where the repository is listed in that file.

Al the best
Philipp

Tareef Kawaf

unread,
Oct 10, 2016, 8:35:39 AM10/10/16
to Philipp Fischer, shinyapps.io Users
Philipp,
shinyapps.io runs on Linux.  We tried to add instructions in the docs to explain that you don't want to be using absolute paths, and to be aware that although you could build your shiny application on any of the supported R versions, it will be recreated on a linux environment on shinyapps.io.

-Tareef

--
You received this message because you are subscribed to the Google Groups "shinyapps.io Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shinyapps-users+unsubscribe@googlegroups.com.
To post to this group, send email to shinyapps-users@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shinyapps-users/de9b0216-d27e-4a34-b76f-2f771f69ae5b%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages