Skip to content

R connection using library RPostgres fails with error "received invalid response to GSSAPI negotiation: R" #227

@mskyttner

Description

@mskyttner

ArcadeDB Version: v21.12.1-SNAPSHOT

JDK Version: arcadedata/arcadedb:latest (docker image)

OS: arcadedata/arcadedb:latest (docker image)

Expected behavior

Attempt to connect using R and RPostgres expected to work, since RJDBC is able to read data from a table in arcadedb.

Actual behavior

Error "received invalid response to GSSAPI negotiation: R"

Steps to reproduce

arcadedb_cmd <- paste(
  "docker run -d -p '2480:2480' -p '2424:2424' -p '5432:5432'",
  "--env arcadedb.server.rootPassword=playwithdata",
  "--env 'arcadedb.server.defaultDatabases=Imported[root]{import:https://github.com/ArcadeData/arcadedb-datasets/raw/main/orientdb/OpenBeer.gz}'", 
  "--env arcadedb.server.plugins='Postgres:com.arcadedb.postgres.PostgresProtocolPlugin'", 
  "arcadedata/arcadedb:latest"
)

cmd <- gsub("\n", "", arcadedb_cmd)

# launch the background service with arcadedb using docker
system(arcadedb_cmd)

# check that it is online using the API
arcadedb_is_up <- function() {
  
  res <- httr::content(
    httr::GET("http://localhost:2480/api/v1/databases", 
    httr::authenticate("root", "playwithdata"))
  )
  
  res$result[[1]] == "Imported"
}

stopifnot(arcadedb_is_up())

# This "works", using RJDBC and the pg jdbc driver

download.file(
  "https://jdbc.postgresql.org/download/postgresql-42.3.1.jar",
  "~/repos/arcadedb/postgresql-42.3.1.jar"
)

library(RJDBC)

drv <- JDBC(
  driverClass = "org.postgresql.Driver", 
  classPath = "~/repos/arcadedb/postgresql-42.3.1.jar", 
  identifier.quote = "`"
)

conn <- dbConnect(drv, 
  paste0("jdbc:postgresql://localhost/Imported",
    "?user=root&password=playwithdata&ssl=false&gssencmode=disable"))

tibble::as_tibble(dbGetQuery(conn, "select * from Brewery limit 10;"))

dbDisconnect(conn)

# Now, attempt to use RPostgres which uses libpg and no Java

library(RPostgres)
library(DBI)

#Sys.setenv(PGGSSENCMODE="disable")
Sys.unsetenv("PGGSSENCMODE")

con <- dbConnect(
  RPostgres::Postgres(),
#  gssencmode = 'disable',
  dbname = 'Imported',
  host = 'localhost',
  port = 5432, 
  user = 'root',
  password = 'playwithdata'
)

# Error: connection to server at "localhost" (127.0.0.1), port 5432 failed: received invalid response to GSSAPI negotiation: R
# Can this be worked around by disabling GSSENCMODE?
# see https://stackoverflow.com/questions/67396081/how-to-configure-a-odbc-connection-to-teiid-on-rhel8-gssapi-negotiation-fails
# and https://blog.hagander.net/connecting-to-azure-postgresql-with-libpq-12-in-a-kerberos-environment-245/

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions