An error has occurred

I've uploaded the shiny app successfully but get the 'An error has occurred' message. The app works locally but is connecting to a database behind a firewall. I may be answering my own question here but would like another opinion based on the log output:

Intial load:-

Preparing to deploy document...DONE
Uploading bundle for document: 5795314...DONE
Deploying bundle: 5651105 for document: 5795314 ...
Waiting for task: 1112644119
building: Building image: 6574476
building: Installing system dependencies
building: Fetching packages
building: Installing packages
building: Installing files
building: Pushing image: 6574476
deploying: Starting instances
rollforward: Activating new instances
success: Stopping old instances
Document successfully deployed to https://shapley.shinyapps.io/RStudio-Projects/
Deployment completed: https://shapley.shinyapps.io/RStudio-Projects/

Shinyapps.io log:-

2022-03-07T10:17:46.059772+00:00 shinyapps[5795314]: Running on host: a320a596a51f
2022-03-07T10:17:46.064475+00:00 shinyapps[5795314]: LANG: C.UTF-8
2022-03-07T10:17:46.064491+00:00 shinyapps[5795314]: rmarkdown version: (none)
2022-03-07T10:17:46.064451+00:00 shinyapps[5795314]: Server version: 2022.02.0
2022-03-07T10:17:46.064509+00:00 shinyapps[5795314]: jsonlite version: 1.7.3
2022-03-07T10:17:46.064526+00:00 shinyapps[5795314]: reticulate version: (none)
2022-03-07T10:17:46.064481+00:00 shinyapps[5795314]: R version: 4.1.2
2022-03-07T10:17:46.064730+00:00 shinyapps[5795314]: Using pandoc: /opt/connect/ext/pandoc/2.16
2022-03-07T10:17:46.064482+00:00 shinyapps[5795314]: shiny version: 1.7.1
2022-03-07T10:17:46.064482+00:00 shinyapps[5795314]: httpuv version: 1.6.5
2022-03-07T10:17:46.064491+00:00 shinyapps[5795314]: knitr version: (none)
2022-03-07T10:17:46.064510+00:00 shinyapps[5795314]: RJSONIO version: (none)
2022-03-07T10:17:46.064520+00:00 shinyapps[5795314]: htmltools version: 0.5.2
2022-03-07T10:17:46.408602+00:00 shinyapps[5795314]: Using jsonlite for JSON processing
2022-03-07T10:17:46.413771+00:00 shinyapps[5795314]:
2022-03-07T10:17:46.414193+00:00 shinyapps[5795314]: Shiny application starting ...
2022-03-07T10:17:46.413773+00:00 shinyapps[5795314]: Starting R with process ID: '27'
2022-03-07T10:17:46.441249+00:00 shinyapps[5795314]: Attaching package: ‘rsconnect’
2022-03-07T10:17:46.441248+00:00 shinyapps[5795314]:
2022-03-07T10:17:46.441850+00:00 shinyapps[5795314]:
2022-03-07T10:17:46.441250+00:00 shinyapps[5795314]:
2022-03-07T10:17:46.441850+00:00 shinyapps[5795314]: The following object is masked from ‘package:shiny’:
2022-03-07T10:17:46.444032+00:00 shinyapps[5795314]: Loading required package: DBI
2022-03-07T10:17:46.441851+00:00 shinyapps[5795314]: serverInfo
2022-03-07T10:17:46.441851+00:00 shinyapps[5795314]:
2022-03-07T10:17:50.925058+00:00 shinyapps[5795314]: Please note that rgdal will be retired by the end of 2023,
2022-03-07T10:17:50.925062+00:00 shinyapps[5795314]: at your earliest convenience.
2022-03-07T10:17:50.925060+00:00 shinyapps[5795314]: plan transition to sf/stars/terra functions using GDAL and PROJ
2022-03-07T10:17:50.925062+00:00 shinyapps[5795314]:
2022-03-07T10:17:50.925067+00:00 shinyapps[5795314]: GDAL binary built with GEOS: TRUE
2022-03-07T10:17:50.925063+00:00 shinyapps[5795314]: rgdal: version: 1.5-28, (SVN revision 1158)
2022-03-07T10:17:50.925066+00:00 shinyapps[5795314]: Geospatial Data Abstraction Library extensions to R successfully loaded
2022-03-07T10:17:50.925069+00:00 shinyapps[5795314]: To mute warnings of possible GDAL/OSR exportToProj4() degradation,
2022-03-07T10:17:50.925066+00:00 shinyapps[5795314]: Loaded GDAL runtime: GDAL 3.0.4, released 2020/01/28
2022-03-07T10:17:50.925070+00:00 shinyapps[5795314]: use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
2022-03-07T10:17:50.925067+00:00 shinyapps[5795314]: Path to GDAL shared files: /usr/share/gdal
2022-03-07T10:17:51.138500+00:00 shinyapps[5795314]: Execution halted
2022-03-07T10:17:50.925068+00:00 shinyapps[5795314]: Path to PROJ shared files: /usr/share/proj
2022-03-07T10:17:51.138503+00:00 shinyapps[5795314]: Shiny application exiting ...
2022-03-07T10:17:50.925068+00:00 shinyapps[5795314]: Linking to sp version:1.4-6
2022-03-07T10:17:50.925068+00:00 shinyapps[5795314]: Loaded PROJ runtime: Rel. 6.3.1, February 10th, 2020, [PJ_VERSION: 631]
2022-03-07T10:17:51.138484+00:00 shinyapps[5795314]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne ->
2022-03-07T10:17:51.138481+00:00 shinyapps[5795314]: Error in value[3L] : RS-DBI driver: (àl·ÁU)
2022-03-07T10:18:26.913531+00:00 shinyapps[5795314]: Running on host: a320a596a51f
2022-03-07T10:18:26.917969+00:00 shinyapps[5795314]: Server version: 2022.02.0
2022-03-07T10:18:26.918018+00:00 shinyapps[5795314]: httpuv version: 1.6.5
2022-03-07T10:18:26.917982+00:00 shinyapps[5795314]: LANG: C.UTF-8
2022-03-07T10:18:26.917988+00:00 shinyapps[5795314]: R version: 4.1.2
2022-03-07T10:18:26.918008+00:00 shinyapps[5795314]: shiny version: 1.7.1
2022-03-07T10:18:26.918096+00:00 shinyapps[5795314]: reticulate version: (none)
2022-03-07T10:18:26.918025+00:00 shinyapps[5795314]: rmarkdown version: (none)
2022-03-07T10:18:26.918083+00:00 shinyapps[5795314]: jsonlite version: 1.7.3
2022-03-07T10:18:26.918035+00:00 shinyapps[5795314]: knitr version: (none)
2022-03-07T10:18:26.918095+00:00 shinyapps[5795314]: RJSONIO version: (none)
2022-03-07T10:18:26.918273+00:00 shinyapps[5795314]: Using pandoc: /opt/connect/ext/pandoc/2.16
2022-03-07T10:18:26.918096+00:00 shinyapps[5795314]: htmltools version: 0.5.2
2022-03-07T10:18:27.223989+00:00 shinyapps[5795314]: Using jsonlite for JSON processing
2022-03-07T10:18:27.229078+00:00 shinyapps[5795314]:
2022-03-07T10:18:27.229078+00:00 shinyapps[5795314]: Starting R with process ID: '53'
2022-03-07T10:18:27.229491+00:00 shinyapps[5795314]: Shiny application starting ...
2022-03-07T10:18:27.256071+00:00 shinyapps[5795314]: Attaching package: ‘rsconnect’
2022-03-07T10:18:27.256070+00:00 shinyapps[5795314]:
2022-03-07T10:18:27.256678+00:00 shinyapps[5795314]: serverInfo
2022-03-07T10:18:27.256071+00:00 shinyapps[5795314]:
2022-03-07T10:18:27.256677+00:00 shinyapps[5795314]: The following object is masked from ‘package:shiny’:
2022-03-07T10:18:27.256678+00:00 shinyapps[5795314]:
2022-03-07T10:18:27.258789+00:00 shinyapps[5795314]: Loading required package: DBI
2022-03-07T10:18:27.256678+00:00 shinyapps[5795314]:
2022-03-07T10:18:31.859911+00:00 shinyapps[5795314]: Please note that rgdal will be retired by the end of 2023,
2022-03-07T10:18:31.859918+00:00 shinyapps[5795314]: at your earliest convenience.
2022-03-07T10:18:31.859919+00:00 shinyapps[5795314]:
2022-03-07T10:18:31.859919+00:00 shinyapps[5795314]: rgdal: version: 1.5-28, (SVN revision 1158)
2022-03-07T10:18:31.859920+00:00 shinyapps[5795314]: Loaded GDAL runtime: GDAL 3.0.4, released 2020/01/28
2022-03-07T10:18:31.859921+00:00 shinyapps[5795314]: Path to PROJ shared files: /usr/share/proj
2022-03-07T10:18:31.859912+00:00 shinyapps[5795314]: plan transition to sf/stars/terra functions using GDAL and PROJ
2022-03-07T10:18:31.859920+00:00 shinyapps[5795314]: Geospatial Data Abstraction Library extensions to R successfully loaded
2022-03-07T10:18:31.859921+00:00 shinyapps[5795314]: Path to GDAL shared files: /usr/share/gdal
2022-03-07T10:18:31.919760+00:00 shinyapps[5795314]: Execution halted
2022-03-07T10:18:31.859921+00:00 shinyapps[5795314]: GDAL binary built with GEOS: TRUE
2022-03-07T10:18:31.919748+00:00 shinyapps[5795314]: Calls: local ... tryCatch -> tryCatchList -> tryCatchOne ->
2022-03-07T10:18:31.919773+00:00 shinyapps[5795314]: Shiny application exiting ...
2022-03-07T10:18:31.859922+00:00 shinyapps[5795314]: Linking to sp version:1.4-6
2022-03-07T10:18:31.859923+00:00 shinyapps[5795314]: use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
2022-03-07T10:18:31.859921+00:00 shinyapps[5795314]: Loaded PROJ runtime: Rel. 6.3.1, February 10th, 2020, [PJ_VERSION: 631]
2022-03-07T10:18:31.859922+00:00 shinyapps[5795314]: To mute warnings of possible GDAL/OSR exportToProj4() degradation,
2022-03-07T10:18:31.919746+00:00 shinyapps[5795314]: Error in value[3L] : RS-DBI driver: (à<oeV)

Shinyapp code:-

library(shiny)
library(shinythemes)
library(rsconnect)
library(RPostgreSQL)
library(rpostgis)
library(sp)
library(rgdal)
library(leaflet)
library(leaflet.extras)
# Specify Driver
pg <- dbDriver("PostgreSQL")
# Connection Details
con <- dbConnect(pg, user ='####', password ="####", host = "####" , port = 5432, dbname="####")
# List all Tables in database (to test the connection)
dbListTables(con)
# Read the PostGIS table "np_owned_land" into a 'data.frame' 
dbReadTable(con, "np_owned_land", schema = "land_management") %>% head(3)
# list the Fields in the table 
dbListFields(con, "np_owned_land", schema = "land_management")
# Query the tables for each layer you require
query <- "SELECT * FROM np_owned_land"
np_owned_land <- pgGetGeom(con, c("land_management","np_owned_land"), geom = "wkb_geometry", gid = "ogc_fid", other.cols = TRUE)
query <- "SELECT * FROM land_ownership"
land_ownership <- pgGetGeom(con, c("land_management","land_ownership"), geom = "wkb_geometry", gid = "ogc_fid", other.cols = TRUE)
# Change the projection from OSGB36 (epsg:27700) to WGS 84 (epsg:4326)
np_owned_land <- spTransform(np_owned_land, CRS("+init=epsg:4326"))
land_ownership <- spTransform(land_ownership, CRS("+init=epsg:4326"))
ui <- fluidPage(theme = shinytheme("cerulean"),
                tags$head(HTML("<title>BBNPA Land Ownership</title> <link rel='icon'type='image/png' href='BBNPA Logo_small_RGB_transparent.png'>")),
                titlePanel(title=div(img(src="myfile.png", style = "padding:5px", height = 130, width = 95, align = "left","Land Ownership"))),
                h4("The land does not include management agreements and other legal interests."),
                p("Owned land and other organisations."),
                leafletOutput("np_owned_land", height = 700))

# Server Function:
server <- function(input, output, session)

output$np_owned_land <- renderLeaflet ({
    map <- leaflet(np_owned_land) %>%
      setView(-3.4710, 51.8633, zoom = 10) %>%
      addTiles(group="OpenStreetMap.Mapnik") %>%
      addProviderTiles("Esri.WorldImagery", group = "Satellite") %>%
      addProviderTiles("OpenStreetMap.HOT", group = "OpenStreetMap.HOT") %>%
      addProviderTiles("Stamen.TerrainBackground", group = "Stamen.TerrainBackground") %>%
      addMiniMap(tiles = "OpenStreetMap.HOT", toggleDisplay = TRUE) %>%
      addSearchOSM() %>%
      addEasyButton(easyButton(icon="fa-globe", title="Zoom to Level 1", onClick=JS("function(btn, map){ map.setZoom(1); }"))) %>%
      addEasyButton(easyButton(icon="fa-crosshairs", title="Locate Me", onClick=JS("function(btn, map){ map.locate({setView: true}); }"))) %>%
      addPolygons(data=np_owned_land,
                  fillColor = "#e41a1c",
                  fillOpacity = 0.4,
                  stroke = "#690E0E",
                  dashArray = "4",
                  weight = 0.7,
                  label = ~name_of_area,
                  labelOptions = labelOptions(style = list("font-weight" = "normal", padding = "3px 8px"), textsize = "13px", direction = "auto"),
                  group = "np_owned_land",
                  highlight = highlightOptions(color = "black", weight = 4, bringToFront = TRUE)) %>%
      addPolygons(data=land_ownership,
                  fillColor = "#377eb8",
                  fillOpacity = 0.4,
                  stroke = "#20445F",
                  dashArray = "4",
                  weight = 0.7,
                  label = ~owner,
                  labelOptions = labelOptions(style = list("font-weight" = "normal", padding = "3px 8px"), textsize = "13px", direction = "auto"),
                  group = "land_ownership",
                  highlight = highlightOptions(color = "black", weight = 4, bringToFront = TRUE)) %>%
      addLegend("bottomleft", title = "Map Legend", colors = c("#e41a1c","#377eb8"), labels = c("NP Owned Land","Land Ownership")) %>%
      addFullscreenControl() %>%
      addMeasure() %>%
      addScaleBar(position = c("bottomleft")) %>%
      addLayersControl(baseGroups = c("OpenStreetMap.Mapnik","Satellite","OpenStreetMap.HOT","Stamen.TerrainBackground"),
                       overlayGroups = c("np_owned_land","land_ownership"),
                       options = layersControlOptions(collapsed = TRUE))
    map
  })
# ShinyApp Function:
shinyApp(ui = ui, server = server)

You have to white list shinyapps.io's IPs on the firewall and allow password authentication to the postgresql database (on the hba.conf file) for those IPs.

The only alternative solution I can think of is to use an ssh tunnel or a VPN connection but I have never tried that on shinyapps.io so I don't know if it is allowed/supported and it would be technically more challenging.

1 Like

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.