Couchbase网络错误16,node.js中的套接字声明失败

Couchbase网络错误16,node.js中的套接字声明失败

问题描述:

我有以下几天运行良好的node.js脚本,但现在却出现此错误:

I have the following node.js script which was running great a couple of days ago but now I get this error:

syd@HP-Notebook:~/Desktop$ node db.js
connected to database
{ [Error: Network error] code: 16 }
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)

,这是db.js的代码:

and here is the code for db.js:

var crypto = require('crypto');
var db = require('couchbase');
var couchBase = null;
var committed = 0;
var intervalID = null;

function strGen(len) {

    var text = '';
    var charset = "abcdefghijklmnopqrstuvwxyz";

    for (var i = 0; i < len; i++) {
        text += charset.charAt(Math.floor(Math.random() * charset.length));
    }

    return text;
}

function numGen(len) {

    var text = '';
    var charset = "0123456789";

    for (var i = 0; i < len; i++) {
        text += charset.charAt(Math.floor(Math.random() * charset.length));
    }

    return text;
}

function newLat() {
    var lat = Math.floor((Math.random() * 2)+1);
    if (lat == 1) return 37;
    return 38;
}

function createDocument() {

    var name = 'Test user #' + committed;
    var licensePlates = strGen(3).toUpperCase() +'-'+ numGen(4);
    var lat = parseFloat(newLat() + '.' + numGen(8));
    var lng = parseFloat('23.' + numGen(8))

    var timestamp = (new Date()).getTime().toString();
    var docKey =  crypto.createHash('md5').update(licensePlates + '-' + name).digest('hex');

    var docData = {
        '_id' : docKey,
        'name' : name,
        'lp' : licensePlates,
        'lat' : lat,
        'lng' : lng,
        'timestamp': timestamp 
    }

    //console.log(docKey);

    //console.log(docData);

    couchBase.set(docKey, JSON.stringify(docData), function(err){
        if (err) { 
            console.log(err); 
        } else if (committed < 1000) {
            committed++;
            console.log('#'+committed + ' - ' + ' Committed: ' + docKey);
        } else {
            clearInterval(intervalID);
            console.log('I\'m done!');
        }
    });

}

db.connect({
    'user':'taxi',
    'password':'taxi',
    'hosts':['127.0.0.1:8091'],
    'bucket':'taxi'
}, function(err, cb) {
    if (err) {
        console.log('TEST');
        console.log(err);
    } else {
        couchBase = cb;
        console.log('connected to database');
        intervalID = setInterval(function(){createDocument(null, null, null)}, 5);
    }
});

过去我没有任何问题。这是在我在ubuntu 12.04中安装php 5.4之后又返回到php 5.3之后发生的,因为我无法使用该版本的php来使该沙发床工作。仅供参考现在,couchbase可以正常工作,但不能与node一起工作。如您所见,与数据库的连接已建立,但set语句失败。任何信息,将不胜感激。

I didn't have any issues in the past. This occurred after I installed php 5.4 in ubuntu 12.04 and then returned to php 5.3 because I couldnt make couchbase work with that version of php. FYI php & couchbase work just fine at the moment, but not with node. As you can see the connection with the database is established but the set statement fails. Any info would be greatly appreciated.

更新

这是另一个脚本中的相同错误:

Here is the same error from another script:

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)

有关此脚本的详细信息来源,请访问: Couchbase网络使用get&时出错设置在bucket.js中

For further info regarding this script & source please visit: Couchbase network error when using get & set in bucket.js

P.S。 memcache与node.js配合正常,我可以获取&组。 ouchnode / couchbase失败!

P.S. memcache is working fine with node.js I can get & set. couchnode/couchbase is failing!

Couchbase C库最近更新为2.1.1,而node.js lib没有。 C库的最新工作版本是2.0.7。要下载它-只需替换掉链接中的版本号即可。站点到2.0.7。

Couchbase C library was updated recently to 2.1.1 and node.js lib wasn't. Lastest working version of C library is 2.0.7. To download it - just replace version number in links from off. site to 2.0.7.

还创建了在沙发床bugtracker上发布。希望它会得到解决。

Also created issue on couchbase bugtracker. Hope it will be fixed.

UPD:已在新的ouchbase nodejs库版本:1.0.0-beta中修复。

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