basho / riak-nodejs-client

The Riak client for Node.js.
Apache License 2.0
72 stars 29 forks source link

Can't connect [JIRA: CLIENTS-779] #136

Closed doronMendelson closed 8 years ago

doronMendelson commented 8 years ago

Hi,

For some reason I can't connect to Riak.

This is the connection line: var client = new Riak.Client(['192.168.56.9:8087']);

client.ping(function(err,res){ if(err) return console.log(err); console.log(res); })

I keep getting this error: No RiakNodes available to execute command.

lukebakken commented 8 years ago

The Client object's initialization is asynchronous. At the time Node.js executes the ping() method, the client may not be fully initialized.

Please use the last argument to the Client object constructor to provide a function to be used as a callback when initialization completes. See the example here.

Please see issue #129, as well. I am considering ways to make it more apparent that these callbacks should be used, or to facilitate knowing when the Client object is ready to use.