Getting error with version 3.x SDK

I’m trying to run this very simple code with Couchbase Node SDK v3.0.5:

const couchbase = require('couchbase'); 

(async () => {
    const options = { username: "test", password: "test123" };
    cluster = new couchbase.Cluster("http://127.0.0.1", options);
    bucket = cluster.bucket("travel-sample");
    collection = bucket.defaultCollection();

    const getResult = await collection.get("airport_1254");
    console.log(getResult);

    cluster.close();
})();

The DB is up and running, the data is there, the credentials are correct. However, I’m getting “Error: cluster object was closed” error (see the screenshot below).
Please note, that the equivalent code with v2.x SDK works fine with the same credentials, network params and query.

Please help to resolve the issue. Thanks.

Couchbase server version: Enterprise Edition 6.6.0 build 7909

@vsr1 can you please help here?

@Karlen91 It is working fine for me.

Here is my package.json

{
“name”: “node-couchbase-project”,
“version”: “1.0.0”,
“description”: “”,
“main”: “index.js”,
“scripts”: {
“test”: “echo “Error: no test specified” && exit 1”
},
“keywords”: ,
“author”: “”,
“license”: “ISC”,
“dependencies”: {
“couchbase”: “^3.0.6”
}
}

Here is the result I got:

{
cas: CbCas { ‘0’: <Buffer 00 00 96 06 d2 d4 15 16> },
content: {
airportname: ‘Calais Dunkerque’,
city: ‘Calais’,
country: ‘France’,
faa: ‘CQF’,
geo: { alt: 12, lat: 50.962097, lon: 1.954764 },
icao: ‘LFAC’,
id: 1254,
type: ‘airport’,
tz: ‘Europe/Paris’
}
}

@raju I just tried again with different Node versions, as well as with dockerized and non-dockerized Couchbase server instances, still getting the same error.
Can you please provide the versions you are using: Node, Couchbase server (with docker or not?), package version and OS. Thanks.

@Karlen91 Here is the information

CBS 6.6 Build 7909 Mac OS Catalina It is not docker
Couchbase Node.js SDK version 3.0.6

@raju Can you please provide the Node.js version as well?

@Karlen91 This command on my Mac gives me
node -v
v12.18.2

With the exact same versions of components I’m still getting the error.

Couchbase Server v6.6.0 (6.6.0 - 7909) - non-Docker
Node v12.18.2
Couchbase SDK v3.0.6
macOS Catalina v10.15.6

@raju can you please confirm that you’ve executed the same, which I’ve shared above? Or you used some other code?

@brett19 @matthew.groves Guys can you please help me to resolve this? What am I doing wrong? Perhaps there’s something else which can make the app to throw this error? (idk, some connection issue, firewall, whatever)

Hey @Karlen91,

Can you try using a connection string of couchbase://127.0.0.1 rather than http://127.0.0.1?

Cheers, Brett

Hey @brett19,
Tried as you said and still getting the same error :((

@Karlen91 As I mentioned in my first reply, I have tried your exact code and shared the output

@brett19 any more thoughts on what. could be the issue?

Hey @Karlen91,

Can you try to use the Administrator username/password rather than a test user?

Cheers, Brett

Hey @brett19, thanks for the reply. The "test"s here are just for demonstrative purposes. I’m using admin user. I even created another user with full access but still getting the same isssue. Any more thoughts? :confused:

@brett19 I’m trying to debug the code inside the Couchbase package. The error I’m getting is “cluster object was closed” and it is being thrown from the “close” method of “Connection” class, but the thing is that I removed this line “cluster.close();” from my usage code. So I wonder, is it ok that it still calls the “connection.close()”?

Update: Ok, so connect is failing, that’s why the close is being called (in cluster._getConn)

Hey @Karlen91,

Can you describe a bit more about the environment you are operating in, and could you try the newly release 3.0.6 SDK? Looking at the logs you posted, it appears that our underlying libcouchbase library set up a timeout for 2s, but that the 2s timer expired nearly immediately. I’ve seen this show up on the forums once before, but have never been able to reproduce it and I don’t believe the user ever posted what had resolved it.

Cheers, Brett

Hey @brett,
As I posted earlier, here’s the environment I’m operating in:

Couchbase Server v6.6.0 (6.> 6.0 - 7909) - non-Docker
Node v12.18.2
Couchbase SDK v3.0.6
macOS Catalina v10.15.6

Please note that the following code (which is pretty much the equivalent code for version 2.x) is working perfectly with the same host/credentials using Couchbase SDK v2.6.12.

const couchbase = require('couchbase');

const username = "test", password = "test123";
cluster = new couchbase.Cluster("couchbase://127.0.0.1");
cluster.authenticate(username, password);
bucket = cluster.openBucket("travel-sample");

bucket.get("airport_1254", { timeout: 60 }, (_, res) => {
    console.log(res);
});

Also I wonder, is it possible to see the exact (underlying) error, which causes the v3 to fail, instead of LCB_ERR_TIMEOUT? And what are some major differences of creating a connection between these 2 versions?

I appreciate your help! Thanks.

@Karlen91 Here is the screenshot of my environment working

Thanks @raju. Unfortunately that doesn’t help much :frowning:
@brett19 any info regarding my last comment?

@brett19 I’ve just tried the same setup on my friend’s MacBook Pro (with macOS Mojave) and still getting the exact same error.