Part 0: Connecting to the analysis servers

Loading the required libraries

To begin, we will load the libraries that will allow us to connect to the Opal analysis servers.

library(DSI)
library(DSOpal)
library(dsBaseClient)

Log in to the study servers

We begin by creating the connection object, to do that we will use the DSI package. It is at this stage that we can decide whether only connect to a single study server or to multiple. If we connect to multiple study servers we can make use of the pooled functionalities of some DataSHIELD functions.

builder <- DSI::newDSLoginBuilder()
builder$append(server = "hm_hospitales",
               url = "https://192.168.1.50:9002",
               user = "user_analisis", password = "**********")
builder$append(server = "sc_verona",
               url = "https://192.168.1.50:8890",
               user = "user_analisis", password = "**********")
builder$append(server = "umf_cluj",
               url = "https://192.168.1.200:8005",
               user = "user_analisis", password = "**********")
builder$append(server = "test_server", # This server will fail!
               url = "https://192.168.1.1:8888",
               user = "test", password = "**********")
logindata <- builder$build()

We just created the logindata object, which contains all the login information, the next step is to use this information and actually connect to the servers.

connections <- DSI::datashield.login(logins = logindata)

Logging into the collaborating servers
Error in curl::curl_fetch_memory(url, handle = handle): schannel: next InitializeSecurityContext failed: SEC_E_UNTRUSTED_ROOT (0x80090325) - La cadena de certificación fue emitida por una entidad en la que no se confía.

The error we are getting is due the study server having no SSL certificate, by default R refuses to connect to endpoints without SSL certificates. We do not need to know what an SSL certificate is or why is it important.

We can maually disable this limitation of R so that it accepts to connect.

library(httr)
set_config(config(ssl_verifypeer = 0L, 
                  ssl_verifyhost = 0L))

And now we successfully connect to the study servers.

connections <- DSI::datashield.login(logins = logindata, failSafe = TRUE)

Logging into the collaborating servers
Warning: test_server is excluded because login connection failed

We can see that if one of the servers fails to connect we get a warning message, but the successful connections get stored into the connections object.