NodeJS SDK 4.2.7 - RequestCanceledError: request canceled - { code: 2 }

Hello everyone.

I’m currently migrating one of our services from the old Node SDK version (2.6.12) to the most recent one (4.2.7).
For testing I run a local couchbase cluster using docker. The version is Enterprise Edition 7.1.3 build 3479.

This is my code (bucket and username are the same):

const uri = "couchbase://localhost:8091"
const bucket = "test";
const pw = "password"

const timeoutOperation = 2;

async function run() {
    const cluster = await cb.connect(uri, {
        "username": bucket,
        "password": pw,
        "timeouts": {
            "kvTimeout": timeoutOperation * 1000
        }
    });
    const openBucket = cluster.bucket(bucket);
    const connection = openBucket.defaultCollection();
}

run();

I get the following error when I run this.

[RequestCanceledError: request canceled] {
  cause: [Error: request_canceled (2)] { code: 2 },
  context: undefined
}

when I use the old couchbase version and our legacy code, it works fine:

async function connectToBucketOld(){
    const cluster = new cbOld.Cluster(uri);

    const connection: cbOld.Bucket = await new Promise((resolve, reject) => {
        let connection;
        const cb = err => (err ? reject(err) : resolve(connection));
        connection = cluster.openBucket(bucket, pw, cb);
    });

    connection.operationTimeout = 1000 * timeoutOperation;
    return { connection };
}

I would be grateful if someone could help me with that

Hi @TimoS – I believe you just need to remove the admin port (8091) from the connection string. You should not need to include the port in the connection string (although there are some exceptions).

Right now the C++ SDK (what the Node.js SDK uses for its core I/O) does not handle bootstrapping via HTTP (see CXXCBC-269).

If still having connection issues, could you also provide logs from running your script (logging docs here)? Should simply be CBPPLOGLEVEL=trace node <your script here>.js

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.