Closed jlai403 closed 8 years ago
Hello,
I need to improve that document. Take a look at this code example:
var Riak = require('basho-riak-client');
var nodes = [
'riak-test:10017',
'riak-test:10027',
'riak-test:10037',
'riak-test:10047'
];
var client = new Riak.Client(nodes, function (err, c) {
// NB: at this point the client is fully initialized, and
// 'client' and 'c' are the same object
});
Note that the Riak.Client
constructor takes a callback argument that is called when the object is ready to execute commands. In your code (and as the rest of the code examples aren't clear about), you have a good chance of trying to execute .ping()
before the Riak.Client
object is actually ready to use. You probably are getting or logging a "no Riak nodes available" error.
If you move the .ping()
call inside of the constructor callback, or use some other synchronization mechanism, your issue will be resolved.
I intend to improve the developer experience with this, see issue #129 and subscribe to it if you'd like to follow progress.
@jlai403 - also see #146
Thanks for using Riak and the Node.js client :smile:
I've tried putting the ping in the callback but I'm still not getting a ping response back. I get the log when I'm in the Riak.Client callback, but not for the ping callback. My test just times out.
test('#ping()', function(done) {
var client = new Riak.Client(['127.0.0.1:8098'], function (err, c) {
assert.isNull(err);
assert.isOk(c);
console.log('Riak.Client');
c.ping(function (err, pong) {
console.log('ping');
assert.isNull(err);
assert.isTrue(pong);
done();
});
});
});
@jlai403 - 8098
is the HTTP port, you need to use 8087
, which is the standard TCP port.
See #156 to follow progress on that particular item.
awesome, thanks for the quick response @lukebakken
Great! Everything resolved then?
Yup, all is good now thanks!
Fixed, or closed via GitHub issues.
[posted via JIRA by Alexander Moore]
I'm following the Getting Started with NodeJS docs but can't seem to ping my local node. I have other similar tests in the same project using another librarie, riak-dc, and have no problem pinging/ storing data.
I'm not sure what I'm missing in my setup.