Unable to connect to Cockroachdb
rishavs opened this issue · 2 comments
rishavs commented
I am having issues connecting to cockroachdb and I wonder if this is the same issue.
my connection string is something like;
postgres://uname@somehosturl.cockroachlabs.cloud:26257/defaultdb?sslmode=verify-full&sslrootcert=cc-ca.crt&options=--cluster=somedbname
Unhandled exception: (DB::ConnectionRefused)
from lib/db/src/db/connection.cr:34:0 in 'initialize'
from lib/pg/src/pg/connection.cr:7:5 in 'new'
from lib/pg/src/pg/driver.cr:3:5 in 'build_connection'
from lib/db/src/db/database.cr:57:9 in '->'
from /usr/share/crystal/src/primitives.cr:255:3 in 'build_resource'
from lib/db/src/db/pool.cr:47:34 in 'initialize'
from lib/db/src/db/pool.cr:40:5 in 'new:initial_pool_size:max_pool_size:max_idle_pool_size:checkout_timeout:retry_attempts:retry_delay'
from lib/db/src/db/database.cr:56:15 in 'initialize'
from lib/db/src/db/database.cr:49:5 in 'new'
from lib/db/src/db.cr:155:5 in 'build_database'
from lib/db/src/db.cr:151:5 in 'build_database'
from lib/db/src/db.cr:119:5 in 'open'
from src/digglu.cr:22:5 in '__crystal_main'
from /usr/share/crystal/src/crystal/main.cr:110:5 in 'main_user_code'
from /usr/share/crystal/src/crystal/main.cr:96:7 in 'main'
from /usr/share/crystal/src/crystal/main.cr:119:3 in 'main'
from __libc_start_main
from _start
from ???
Caused by: CodeParamsRoutingFailed: rejected by BackendConfigFromParams: Invalid cluster name (PQ::PQError)
from lib/pg/src/pq/connection.cr:203:7 in 'handle_error'
from lib/pg/src/pq/connection.cr:186:7 in 'handle_async_frames'
from lib/pg/src/pq/connection.cr:162:7 in 'read'
from lib/pg/src/pq/connection.cr:157:7 in 'read'
from lib/pg/src/pq/connection.cr:414:31 in 'expect_frame'
from lib/pg/src/pq/connection.cr:413:5 in 'expect_frame'
from lib/pg/src/pq/connection.cr:242:20 in 'connect'
from lib/pg/src/pg/connection.cr:14:9 in 'initialize'
from lib/pg/src/pg/connection.cr:7:5 in 'new'
from lib/pg/src/pg/driver.cr:3:5 in 'build_connection'
from lib/db/src/db/database.cr:57:9 in '->'
from /usr/share/crystal/src/primitives.cr:255:3 in 'build_resource'
from lib/db/src/db/pool.cr:47:34 in 'initialize'
from lib/db/src/db/pool.cr:40:5 in 'new:initial_pool_size:max_pool_size:max_idle_pool_size:checkout_timeout:retry_attempts:retry_delay'
from lib/db/src/db/database.cr:56:15 in 'initialize'
from lib/db/src/db/database.cr:49:5 in 'new'
from lib/db/src/db.cr:155:5 in 'build_database'
from lib/db/src/db.cr:151:5 in 'build_database'
from lib/db/src/db.cr:119:5 in 'open'
from src/digglu.cr:22:5 in '__crystal_main'
from /usr/share/crystal/src/crystal/main.cr:110:5 in 'main_user_code'
from /usr/share/crystal/src/crystal/main.cr:96:7 in 'main'
from /usr/share/crystal/src/crystal/main.cr:119:3 in 'main'
from __libc_start_main
from _start
from ???
One of the reasons why I want to use Cdb is its support for ssl connections and was hoping that I could use it in my crystal api.
bcardiff commented
cyangle commented
@rishavs You need to add the cluster name to the db name as prefix, and also enable cleartext
auth methods:
postgres://uname@somehosturl.cockroachlabs.cloud:26257/somedbname.defaultdb?auth_methods=cleartext,md5,scram-sha-256&sslmode=verify-full&sslrootcert=cc-ca.crt
But sslmode=verify-full
is not implemented.