Couchbase network error when using get & set in bucket.js

﹥>﹥吖頭↗ 提交于 2020-01-05 09:23:32

问题


I have this simple js script:

var cb = require('couchbase');
var bucket;
var connectionSettings = {
                            'user':'test-bucket',
                            'password':'test',
                            'hosts':['localhost:8091'],
                            'bucket':'test-bucket'
                         };

cb.connect(connectionSettings, function(e, bucket) {

    if (e) {

        errorHandler('connect', e);

    } else {

        console.log('Connection established!');

        bucket.get('testObject', function(e, doc) {
            if(e) {
                errorHandler('get', e);
            } else {
                console.log(doc);
            }       
        });

    }

});

function errorHandler(from, e) {

    console.log('Function: ' + from);
    console.log(e.message);
    console.log(e.stack);

}

After executing it a connection is being established, but when I try to get the document with id 'a' in this test case I get the following error:

syd@HP-Notebook:~/Desktop$ node test.js
Connection established!
Function: get
Network error
Error: Network error
    at makeError (/home/syd/node_modules/couchbase/lib/bucket.js:578:18)
    at getParsedHandler (/home/syd/node_modules/couchbase/lib/bucket.js:625:17)
node: ../src/ioplugin.cc:496: virtual int Couchnode::IoOps::updateEvent(lcb_socket_t, void*, short int, void*, void (*)(lcb_socket_t, short int, void*)): Assertion `socket != __null' failed.
Aborted (core dumped)

Furthermore here are the code snippets where these errors occur in bucket.js.

578:

function makeError(conn, errorCode) {
    // Early-out for success
    if (errorCode == 0) {
        return null;
    }

    // Build a standard NodeJS Error object with the passed errorCode
    var errObj = new Error(conn.strError(errorCode)); // <- 578 error here
    errObj.code = errorCode;
    return errObj;
}

625:

function getParsedHandler(data, errorCode, key, cas, flags, value) {
    // if it looks like it might be JSON, try to parse it
    if (/[\{\[]/.test(value)) {
        try {
            value = JSON.parse(value);
        } catch (e) {
        // console.log("JSON.parse error", e, value)
        }
    }
    var error = makeError(data[1], errorCode); // <- 625 error here
    data[0](error, value, {
        id : key,
        cas: cas,
        flags : flags
    });
}

Any ideas why this is happening ? P.S. I have no issues mining data from PHP.


回答1:


It fails for the same reason as in this question. Downgrading libcouchbase to 2.0.7 should solve issue.

UPD: "Fixed" in new couchbase nodejs library release 1.0.0-beta.



来源:https://stackoverflow.com/questions/18379115/couchbase-network-error-when-using-get-set-in-bucket-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!