Forum: Building VoltDB Applications

Post: NodeJs Client for HelloWorld

NodeJs Client for HelloWorld
theschmitzer
Feb 7, 2013
I'm trying (and failing) to write a nodejs client for the helloworld tutorial using voltdb 3.0. I have installed the npm package voltjs, and have been unable to connect.

The DB is running on localhost with this command:

$ voltdb create catalog helloworld.jar deployment deployment.xml host localhost

My minimal client to connect looks like this:

$ cat helloclient.js
var VoltClient = require('voltjs/lib/client')
, VoltConstants = require('voltjs/lib/voltconstants')
;

var config = [{ host: "localhost", messageQueueSize: 20 }];
var client = new VoltClient(config);

client.connect(function(code, evt, results) {
console.log("connect code: " + VoltConstants.STATUS_CODE_STRINGS
);
}, function(results) {
console.log("Error " + results);
});

I would expect a successful connection to call the first function, and an error to call the second, however, running it I see the first is called with an error:

$ node helloclient.js
connect code: UNEXPECTED_FAILURE

Questions:
* Why would a failure NOT call the error callback
* Is a license.xml file required for voltdb 3.0 - the documentation shows starting commands with a licsense param, but I have none in my installation dir?
* Why is it failing to connect?
* I think the deployment.xml needs jsonapi support, is this true? (I included it)
* Is something additional needed on the command line for node clients?
* Is there a log that gives any connect info?
* Are nodejs clients supported in the Community Edition?

TIA

jeff
theschmitzer
Feb 7, 2013
Update: I have also tried using the node client download from http://voltdb.com/downloads/technologies/client/voltdb-client-nodejs-1.0.tar.gz

This gives the error

connect code: Error: connect ECONNREFUSED

I assume the npm package is the "new" version, and this client lib is the "old" version, since it does not have VoltConstants.js for example.

Still confused on the above questions
jpiekos
Feb 7, 2013
Quick suggestion: can you run the voter client supplied in the node client examples directory? I just ran it and it worked great.

* Is a license.xml file required for voltdb 3.0 - the documentation shows starting commands with a licsense param, but I have none in my installation dir?

License.xml is only required if you are using VoltDB Enterprise. No need with community version.

* I think the deployment.xml needs jsonapi support, is this true? (I included it)


No.

* Is something additional needed on the command line for node clients?


Shouldn't be. Try the voter sample supplied with the client kit - did that work for you?

* Are nodejs clients supported in the Community Edition?

Yes. Absolutely.

John
theschmitzer
Feb 8, 2013
Thanks John,

I figured out the problem, and it was this line:

var config = [{ host: "localhost", messageQueueSize: 20 }];
Should have been:

var config = new VoltConfiguration();
config.host = "localhost";
config.messageQueueSize = 20;

Just creating the literal object was missing the default values that VoltConfiguration provides.
theschmitzer
Feb 8, 2013
Thanks John,

I figured out the problem, and it was this line:

var config = [{ host: "localhost", messageQueueSize: 20 }];
Should have been:

var config = new VoltConfiguration();
config.host = "localhost";
config.messageQueueSize = 20;

Just creating the literal object was missing the default values that VoltConfiguration provides.
jpiekos
Feb 8, 2013
Excellent, thanks for the update Jeff. Would love to hear what you are building with node.js and VoltDB.

John