xo / dburl

Package dburl provides a standard, URL style mechanism for parsing and opening SQL database connection strings
MIT License
272 stars 37 forks source link

couchbase error: n1ql: Connection failed Post #36

Closed mateors closed 7 months ago

mateors commented 8 months ago

I tried with the following command

usql -c "SELECT username from login;" couchbase://pass:pass@213.255.246.203/master_erp

I got the following error:

error: n1ql: Connection failed Post "http://user:pass@213.255.246.203:9000/master_erp/query/service": dial tcp 213.255.246.203:9000: connectex: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
N1QL: Unable to connect to cluster endpoint http://user:pass@213.255.246.203:9000/master_erp. Error Get "http://213.255.246.203:9000/pools": context deadline exceeded (Client.Timeout exceeded while awaiting headers)

Anyone can help me to fix the issue?

kenshaw commented 8 months ago

Is your port 9000 open? Note you just shared your username and password for what appears to be a public IP.

mateors commented 7 months ago

@kenshaw Thank you for you comment, I’ve removed the credentials, While port 9000 is allowed in the firewall, I’m unable to observe it listening in the network service. The challenge lies in my inability to switch the port to either 8091 or 8093. Is there a way to modify the default port from 9000 to 8093?

kenshaw commented 7 months ago

You can always use the port in the URL -- usql couchbase://host:8093/. That said, the out of the box testing setup for usql no longer seems to work with the most recent/updated Couchbase container (Docker) image. I'll look into what's changed and work on this.

kenshaw commented 7 months ago

After setting up a database via the Admin UI, and using the "out of the box" config I've been testing/developing with for Couchbase, this works just fine:

usql couchbase://Administrator:P4ssw0rd@localhost:8093/

Where Administrator and P4ssw0rd are the administrator user/pass that was set up during the Couchbase install.

With regards to changing the default port to 9000, I believe the history/issue with this is that Couchbase changed the port that N1QL ran on (or it used to be accessible on multiple ports). I'll change this in dburl, but note that this shouldn't be a barrier to using usql.

kenshaw commented 7 months ago

I just pushed changes to dburl and to usql that change the default port for the Couchbase (N1QL) driver to 8093. Please note that based on my very cursory / superficial examination of the Couchbase driver, I don't think it's going to work out well for use with usql, as it's very non-standard in how it treats/returns records from the database. That's somewhat to be expected, given that it is not a traditional row-based database.

usql is undergoing a heavy rewrite at the moment, so I'm not cutting a new release at this time. Please install/build from source if you need these latest changes.

mateors commented 7 months ago

@kenshaw Thank you for your prompt assistance. I have developed my own Couchbase library for working with N1QL, and it functions seamlessly without any issues. You can find it on GitHub: mateors/mcb. If you believe that Couchbase is not an ideal candidate for usql , I recommend removing it from the documentation

kenshaw commented 7 months ago

@mateors I'll take a look at your package. If you'd like your package to be integrated to usql, all you need to do is provide a standard database/sql interface, and I would gladly incorporate it. As it stands, I believe I have added all standard database/sql drivers into usql that can feasibly be integrated.

mateors commented 7 months ago

@kenshaw Certainly, I will diligently work on the task and provide an update once it is completed. I must express my admiration for your exceptional usql; it truly stands out. My purpose here is to seamlessly integrate it with Couchbase. I hold a deep appreciation for Couchbase due to its extensive feature set, which significantly contributes to building robust and scalable systems.

mateors commented 7 months ago

@kenshaw i just build your recent usql update and got the following output. couchbase_error

it seems usql couchbase://Administrator:pass@localhost:8093 this works!

but usql -c "SELECT 1;" couchbase://Administrator:pass@localhost:8093/master_erp this not working