Connecting couchbase with nodejs - invalid_argument

Viewed 29
async function cb() {
  const clusterConnStr = "couchbases://localhost:8091";
  const username = "Administrator";
  const password = "xxx";
  try {
    const cluster = await couchbase.connect(clusterConnStr, {
      username: username,
      password: password,
      timeouts: {
        kvTimeout: 10000, // milliseconds
      },
    });
    console.log("Connected....");
  } catch (e) {
    console.log(e);
  }
}

cb();

I am getting the following error.

[Error: invalid_argument] { code: 3 }

Couchbase version

"couchbase": "^4.1.2"

Couchbase is working locally enter image description here

Not sure why I am getting this error, any help would be appreciated.

1 Answers

I think you are mostly right the only issue is your placement or parameter values can you try like this:

async function cb() {
  const clusterConnStr = "couchbase://127.0.0.1/?connectionTimeout=1200";
  const username = "Administrator";
  const password = "xxx";
  try {
    const cluster = await couchbase.connect(clusterConnStr, {
      username: username,
      password: password
    });
    console.log("Connected....");
  } catch (e) {
    console.log(e);
  }
}
Related