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

Parsing for multihost #29

Closed
kalemayur8 opened this issue Mar 27, 2020 · 4 comments
Closed

Parsing for multihost #29

kalemayur8 opened this issue Mar 27, 2020 · 4 comments

Comments

@kalemayur8
Copy link

kalemayur8 commented Mar 27, 2020

Hi There,

I was trying to parse the below URL , but it is returning null

const h = ConnectionString.parseHost('[server.site1.company.com::]:1512); console.log(h);

prints null on console.

Basically I want to create multihost string like below

postgres://user:[email protected]:1512,[server2.site2.company.com::]:1512/dbname?target_session_attrs=read-write

@vitaly-t
Copy link
Owner

vitaly-t commented Mar 27, 2020

That's because [server.site1.company.com::] does not adhere to any valid address format. You are taking a domain address, and trying to treat it as if it were an IPv6 address.

@kalemayur8
Copy link
Author

kalemayur8 commented Mar 28, 2020

@vitaly-t any suggestion on how it should be with the domain name? is below string is correct?

I am using pg library for postgres connection.

const conn = new ConnectionString('postgres://server1.site1.company.com:1512,server2.site2.company.com:1512/dbname?target_session_attrs=read-write');
conn.setDefaults({user:'user',password:'password'});

it forms correct string I guess, but while trying to connect with DB fails here

[ { name: 'server1.site1.company.com',
    type: 'domain',
    port: 1512 },
  { name: 'server2.site2.company.com',
    type: 'domain',
    port: 1512 } ]
(node:13772) UnhandledPromiseRejectionWarning: error: database ":1512,server2.site2.company.com/dbname" does not exist
    at Connection.parseE (node_modules\pg\lib\connection.js:604:13)
    at Connection.parseMessage (node_modules\pg\lib\connection.js:403:19)

@vitaly-t
Copy link
Owner

vitaly-t commented Mar 28, 2020

but while trying to connect with DB fails here

Why your database server does not recognize a connection - probably because it does not support multi-host configurations. But that's not relevant for investigation here. That's the driver's issue.

And as for the pg driver - it does not support multi-host configurations, AFAIK. See here.

@vitaly-t
Copy link
Owner

As far as Parsing for multi-host goes here, I believe this has been sorted, so I am closing the issue.

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

2 participants