Using cockroachdb / postgresql in an iOS swift app

62 views Asked by At

I'm trying to connect to a cockroachdb instance from within an iOS app being developed on Xcode. I am using the PostgresClientKit. I get an error saying:

localizedSeverity: Fatal
code: 0C800
message: codeProxyRefusedConnection: connection refused 

Has anyone used this library or any other to successfully pull data from cockroach into an iOS app?

I tried the following code:

import PostgresClientKit

var configuration = PostgresClientKit.ConnectionConfiguration()
configuration.host = “host.cockroachlabs.cloud"
configuration.database = “server.table”
configuration.user = “username”
configuration.port = 12345
configuration.credential = .scramSHA256(password: “pass”)
let connection = try PostgresClientKit.Connection(configuration: configuration)

I was expecting it to connect successfully.

1

There are 1 answers

0
alyshan On

I think you need to specify the host parameter correctly. Where did you get host.cockroachlabs.cloud from?

You should see the hostname for connecting to your CRDB cluster from the connect modal in the cluster overview page.

For example it could look something like this: klutzy-ent-6246.g8z.cockroachlabs.cloud

connect modal for my serverless cluster