Hey guys:
This is a weird problem I am encountering in my Shiny app. I went to a local R user mixer, and no one had a clue (well they did gave me advice to post it here):
First of all the app works totally fine in runApp() in my RStudio. But after I deploy it onto my shinyapps.io account and run it in my Chrome browser, it returns message: Error: cannot open the connection.
I did some tracking and figured out that the problem is with this line of code: form_d<-read.table(url(HTML_table[i]),fill=TRUE) with HTML_table[i] being a vector of urls linking to some SEC forms (so I guess it's not because of internet security settings).
Here are some things that I tried:
url(). Doesn't work.HTML_table[i]Â with the original url string. Doesn't work.setInternet2(TRUE). Works when in runApp() in RStudio, but results in shiny app disconnected from server in shinyapps.io.HTML_table[i]Â works completely fine in the test Shiny app, both in RStudio and in shinyapps.io.Based on part 4, I was wondering maybe it was a setting problem? Here is a list of my libraries:
shiny
DT
RCurl
stringr
XMLand options:
> options()
$add.smooth
[1] TRUE
$askpass
function (prompt)
{
.Call(.rs.routines$rs_askForPassword, prompt)
}
<environment: 0x000000000a5c2428>
$browser
function (url)
{
.Call(.rs.routines$rs_browseURL, url)
}
<environment: 0x0000000009b64920>
$browserNLdisabled
[1] FALSE
$buildtools.check
function (action)
{
if (identical(.Platform$pkgType, "mac.binary.mavericks")) {
.Call(.rs.routines$rs_canBuildCpp)
}
else {
if (!.Call("rs_canBuildCpp")) {
.rs.installBuildTools(action)
FALSE
}
else {
TRUE
}
}
}
<environment: 0x000000000a5c2428>
$buildtools.with
function (code)
{
.rs.addRToolsToPath()
on.exit(.rs.restorePreviousPath(), add = TRUE)
force(code)
}
<environment: 0x000000000a5c2428>
$CBoundsCheck
[1] FALSE
$check.bounds
[1] FALSE
$citation.bibtex.max
[1] 1
$continue
[1] "+ "
$contrasts
unordered ordered
"contr.treatment" "contr.poly"
$defaultPackages
[1] "datasets" "utils" "grDevices" "graphics" "stats" "methods"
$demo.ask
[1] "default"
$deparse.cutoff
[1] 60
$device
[1] "RStudioGD"
$device.ask.default
[1] FALSE
$digits
[1] 7
$download.file.method
[1] "wininet"
$echo
[1] TRUE
$editor
function (name, file, title)
{
if (is.null(name) || is.function(name)) {
if (is.null(name)) {
if (!is.null(file) && nzchar(file))
targetFile <- file
else targetFile <- scratchFile
}
else {
functionSrc <- .rs.deparseFunction(name, TRUE, FALSE)
targetFile <- scratchFile
writeLines(functionSrc, targetFile)
}
if (.Call("rs_editFile", targetFile)) {
newFunc <- try(eval.parent(parse(targetFile)), silent = TRUE)
if (inherits(newFunc, "try-error")) {
stop(newFunc, "You can attempt to correct the error using ",
title, " = edit()")
}
return(newFunc)
}
else {
stop("Error occurred while editing function '", name,
"'")
}
}
else edit(name, file, title, editor = defaultEditor)
}
<environment: 0x000000000c0dca10>
$encoding
[1] "native.enc"
$error
(function ()
{
.rs.breakOnError(TRUE)
})()
$example.ask
[1] "default"
$expressions
[1] 5000
$ggvis.renderer
[1] "svg"
$help.search.types
[1] "vignette" "demo" "help"
$help.try.all.packages
[1] FALSE
$help_type
[1] "html"
$HTTPUserAgent
[1] "R (3.2.5 x86_64-w64-mingw32 x86_64 mingw32)"
$httr_oauth_cache
[1] NA
$httr_oob_default
[1] FALSE
$install.packages.compile.from.source
[1] "interactive"
$internet.info
[1] 2
$java.parameters
[1] "-Xmx512m"
$keep.source
[1] TRUE
$keep.source.pkgs
[1] FALSE
$locatorBell
[1] TRUE
$mailer
[1] "mailto"
$max.print
[1] 10000
$menu.graphics
[1] FALSE
$na.action
[1] "na.omit"
$nwarnings
[1] 50
$OutDec
[1] "."
$pager
function (files, header, title, delete.file)
{
for (i in 1:length(files)) {
if ((i > length(header)) || !nzchar(header[[i]]))
fileTitle <- title
else fileTitle <- header[[i]]
.Call(.rs.routines$rs_showFile, fileTitle, files[[i]],
delete.file)
}
}
<environment: 0x000000000a5c2428>
$papersize
[1] "letter"
$pdfviewer
[1] "C:/PROGRA~1/R/R-32~1.5/bin/x64/open.exe"
$pkgType
[1] "both"
$prompt
[1] "> "
$RCurlOptions
$RCurlOptions$cainfo
[1] "D:/Documents/R/win-library/3.2/RCurl/etc/ca-bundle.crt"
$repos
CRAN CRANextra
"https://cran.rstudio.com/" "http://www.stats.ox.ac.uk/pub/RWin"
attr(,"RStudio")
[1] TRUE
$restart
function (afterRestartCommand = "")
{
afterRestartCommand <- paste(as.character(afterRestartCommand),
collapse = "\n")
.Call(.rs.routines$rs_restartR, afterRestartCommand)
}
<environment: 0x000000000a5c2428>
$scipen
[1] 999
$shiny.launch.browser
function (url)
{
invisible(.Call("rs_shinyviewer", url, getwd(), 3))
}
<environment: 0x000000000a5c2428>
attr(,"shinyViewerType")
[1] 3
$shinygadgets.showdialog
function (caption, url, width = NULL, height = NULL)
{
if (!is.character(caption) || (length(caption) != 1))
stop("caption must be a single element character vector.",
call. = FALSE)
if (!is.character(url) || (length(url) != 1))
stop("url must be a single element character vector.",
call. = FALSE)
if (is.null(width))
width <- 600
if (is.null(height))
height <- 600
if (!is.numeric(width) || (length(width) != 1))
stop("width must be a single element numeric vector.",
call. = FALSE)
if (!is.numeric(height) || (length(height) != 1))
stop("height must be a single element numeric vector.",
call. = FALSE)
invisible(.Call("rs_showShinyGadgetDialog", caption, url,
width, height))
}
<environment: 0x0000000009b64920>
$show.coef.Pvalues
[1] TRUE
$show.error.messages
[1] TRUE
$show.signif.stars
[1] TRUE
$str
$str$strict.width
[1] "no"
$str$digits.d
[1] 3
$str$vec.len
[1] 4
$str.dendrogram.last
[1] "`"
$stringsAsFactors
[1] TRUE
$timeout
[1] 60
$ts.eps
[1] 0.00001
$ts.S.compat
[1] FALSE
$unzip
[1] "internal"
$useFancyQuotes
[1] TRUE
$verbose
[1] FALSE
$viewer
function (url, height = NULL)
{
if (!is.character(url) || (length(url) != 1))
stop("url must be a single element character vector.",
call. = FALSE)
if (identical(height, "maximize"))
height <- -1
if (!is.null(height) && (!is.numeric(height) || (length(height) !=
1)))
stop("height must be a single element numeric vector or 'maximize'.",
call. = FALSE)
invisible(.Call("rs_viewer", url, height))
}
<environment: 0x0000000009b64920>
$warn
[1] 0
$warning.length
[1] 1000
$width
[1] 94
$windowsTimeouts
[1] 100 500
$xlsx.date.format
[1] "m/d/yyyy"
$xlsx.datetime.format
[1] "m/d/yyyy h:mm:ss"It might also be related to shinyapps.io server settings, but i have no idea where to check that.
Anyone have any ideas?