Couchbase Server NodeJS SDK Cluster.openbucket 打开连接需要 58 秒

Couchbase Server NodeJS SDK Cluster.openbucket Takes 58 Seconds to Open a Connection

我正在使用 NodeJS SDK。在下面的基本示例中,我打开一个桶来插入一条记录。我已经把每个方法都放在一个承诺中,一个接一个地(顺序地)强制它们 运行 这样我就可以测量每个方法的 运行ning 时间。

我的 OS: Ubuntu 16.04

'use strict';

const couchbase = require('couchbase');
const cluster = new couchbase.Cluster('couchbase://localhost');
const uuid = require('uuid/v4');

console.time('auth');
cluster.authenticate('administrator', 'adminadmin');
console.timeEnd('auth');

function open() {
    return new Promise((resolve, reject) => {
        console.time('open');

        let bucket = cluster.openBucket('test', function (err) {
            if (err) {
                console.error(err);
                reject(err);
            }            
            resolve(bucket);
        });
    });
}

function insert(bucket, obj) {
    return new Promise((resolve, reject) => {
        console.time('upsert');

        bucket.upsert(`uuid::${blog.name}`, blog, function (err, result) {            
            if (err) {
                console.log(err);
                reject(err);                
            }
            resolve(bucket);
        });
    });
}

function dc(bucket) {    // disconnect
    return new Promise((resolve, reject) => {       
        console.time('dc');

        bucket.disconnect();
        resolve('ok');
    });
}

// data to insert
let blog = {
    id: uuid(),
    name: 'Blog A',
    posts: [
        {
            id: uuid(),
            title: 'Post 1',
            content: 'lorem ipsum'
        }
    ]
};

open().then((bucket) => {
    console.timeEnd('open');

    insert(bucket, blog).then((bucket) => {        
        console.timeEnd('upsert');

        dc(bucket).then((res) => {            
            console.timeEnd('dc');
            console.log(res);
        });
    });
});

输出为:

auth: 0.237ms
open: 58117.771ms <--- this shows the problem
upsert: 57.006ms
dc: 0.149ms
ok

我运行 sdk-博士。它给了我两行值得一提的内容:

  1. “警告:您的连接字符串仅指定了一个主机。您应该考虑将集群中的其他静态节点添加到此列表中,以改进您的应用程序容错运行ce”
  2. “信息:获取集群信息失败(状态码:401)”

总结如下:

总结: [警告] 您的连接字符串仅指定了一个主机。您应该考虑将集群中的其他静态节点添加到此列表以改进您的应用程序容错运行ce

有人愿意帮忙吗?

根据 Couchbase 论坛中 this answer 的说法,似乎我的 DNS 服务器配置不正确。

It looks as though your DNS servers may be configured improperly. As part of the normal bootstrap procedure, we attempt to resolve SRV records for the hostname that is provided, it looks like you’re DNS servers may be timing out when trying to do this, causing a substantial delay when connecting. A quick way to test this theory is to add an additional hostname to your bootstrap list to disqualify the connection string from our DNS-SRV policy (for instance, use: couchbase://localhost,invalidhostname).