2

I'm trying to connect to a database via SSL using the code suggested here: https://github.com/ropensci/ssh/issues/13 I listed the dummy code below that shows how I enable the connection and try to query some data. The solution works great for 'smaller' queries. However, when I try to get 'larger' data, the query fails and R gives back the following error: System failure for: recv() from user (Connection reset by peer) follwed by a fetching error Failed to fetch row: SSL error: decryption failed or bad record mac (see output in code snipped)

Accordingly to the 1st error message, I suppose the error occurs served-sided ('reset by peer' --> What does "connection reset by peer" mean?). Is that true or is there a way to fix this error on the client side (in R)?

ssh::ssh_read_key(file = ssh::ssh_home("id_rsa"), password = "rsa_password")
cmd <- "session <- ssh::ssh_connect('user@host:port');ssh::ssh_tunnel(session, port = 5432, target = '127.0.0.1:5432')"
pid <- sys::r_background(std_out = T, args = c("-e", cmd))

dbcon <-DBI::dbConnect(drv = RPostgres::Postgres(),
                       dbname = "db_name",
                       host = "127.0.0.1",
                       port = 5432,
                       user = "db_user",
                       password = "db_password",
                       base::list(sslmode="require"),
                       service = NULL)


# example of working query 
res <- DBI::dbGetQuery(conn = dbcon, statement = "SELECT * FROM small_table") # 

# example of non-working query (see R-otutput)
res <- DBI::dbGetQuery(conn = dbcon, statement = "SELECT * FROM large_table;") #

## R-output
# Tunneled 31897311 bytes...Fehler: System failure for: recv() from user (Connection reset by peer)
# Ausführung angehalten
# Fehler: Failed to fetch row: SSL error: decryption failed or bad record mac
# Warnmeldung:
# Disconnecting from unused ssh session. Please use ssh_disconnect()
guessr
  • 21
  • 1
  • 3
  • What error does the PostgreSQL server report in its log file? – jjanes Aug 09 '21 at 13:07
  • The log for the failed query is the following one: FATAL: connection to client lost – guessr Aug 09 '21 at 13:53
  • If one side reports it was reset, and the other reports it was lost, that sounds like a firewall or gateway is actively interfering with you. – jjanes Aug 09 '21 at 22:53

1 Answers1

-1

"Connection reset by peer" means that whatever you have tried connecting to has responded in an RST flag, meaning that they have reset the connection.