Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to connect to Cockroachdb #231

Open
rishavs opened this issue Jul 1, 2021 · 2 comments
Open

Unable to connect to Cockroachdb #231

rishavs opened this issue Jul 1, 2021 · 2 comments

Comments

@rishavs
Copy link

rishavs commented Jul 1, 2021

I am having issues connecting to cockroachdb and I wonder if this is the same issue.

my connection string is something like;
postgres://[email protected]: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
Copy link
Collaborator

bcardiff commented Jul 1, 2021

@rishavs I think the situation you are in is the same as #136. PR are welcome accordingly to #113.

@cyangle
Copy link

cyangle commented Dec 15, 2021

@rishavs You need to add the cluster name to the db name as prefix, and also enable cleartext auth methods:
postgres://[email protected]:26257/somedbname.defaultdb?auth_methods=cleartext,md5,scram-sha-256&sslmode=verify-full&sslrootcert=cc-ca.crt
But sslmode=verify-full is not implemented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants