Shiny app hosted on AWS loads UI, but server logic doesn't get executed

Shiny app works locally and is able to query on redshift cluster with no issues.
The app itself connects to a redshift cluster and basically executes a query on button click.

I have tested using the package RJDBC and RPostgres and both seem to not work when deployed on EC2.
Both RJDBC and RPostgres results in the same error.

library(RJDBC) 
# connect to Amazon Redshift use with RJDBC, driver has been downloaded to within /srv/shiny-server/app
  driver <- JDBC("com.amazon.redshift.jdbc41.Driver", "./RedshiftJDBC41-1.1.9.1009.jar", identifier.quote="`")
  url <- "jdbc:redshift://redshift host cluster info"
  conn <- dbConnect(driver, url)

#if using RPostgres
library(RPostgres)
  conn <- dbConnect(RPostgres::Postgres(), host="RSclust...", port="8080", dbname="db",  user="dbuser",  password="pass", sslmode='require')

The error I'm getting on chrome console is "2 message(s) discarded from buffer", but that doesn't tell me anything further. No error logs on /var/log/shiny-server

Attaching package: ‘DT’
The following objects are masked from ‘package:shiny’:
    dataTableOutput, renderDataTable
Loading required package: DBI
Loading required package: rJava

When using a single file app.R instead of the above server.R/ui.R. The error messages are different and UI doesn't load as I have placed the connection part outside of the UI and Server sections.
Using RPostgres

Error: could not connect to server: Connection timed out
        Is the server running on host "redshift.cluster" (168.0.0.0) and accepting
        TCP/IP connections on port 8080?
Execution halted

I am assuming that port might be blocked or not opened? Again this works fine locally just not on EC2. Do I need to open up ports on the hosted EC2 server?

Using RJDBC. this is a new error as previous attempts did not run into this error which is weird

Error in dbConnect(driver, url) :
  Unable to connect JDBC to jdbc:redshift://redshift.amazonaws.com:8080/dbname?user=user&password=pass&ssl=true
  JDBC ERROR: [Amazon](500150) Error setting/closing connection: Connection timed out.
Calls: runApp ... dbConnect -> .local -> .verify.JDBC.result -> .verify.ex
Execution halted

Hi @blitz ,

Welcome to RStudio Community :partying_face: :partying_face: :partying_face: :partying_face: :partying_face: :partying_face: :partying_face:

I was thinking... do these packages require external dependencies (external to R) that you need to install on your Ubuntu server (I suppose)?

@gueyenono thanks!
the packages don't require external dependencies and I don't think they do. Error doesn't seem to indicate any missing dependencies.

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