Connect to Cassandra via NodeJS script

I know that tighter integration with Cassandra is on the horizon, but I thought I would be able to write a NodeJS script that uses the NodeJS Cassandra driver to connect and execute queries. However, the call to connect to the database seems to be hanging in the cassandra driver code somewhere. I do not see any log entries, nor do I get a timeout.

I am able to successfully create the Cassandra client object and verified that it is configured correctly before attempting to connect to the database. I also verified that the call is getting into the driver’s code by manually setting the “connected” property of the client to true before making the call to Connect. This returns as expected, because the driver does not attempt to connect is the client is already connected.

Here is an example of my script:

var cassandra = require('/path/to/nodejs/modules/cassandra-driver'); var options = { contactPoints: ['cassandraserver'], authProvider: new cassandra.auth.PlainTextAuthProvider('username', 'password') } var client = new cassandra.Client(options); client.connect(function(err, result) { console.log('Connected'); }); return {success: 'yay'};

1 Like

Can you try running your script on command line and see if it works there. If it hangs there too then you can troubleshoot it better on command line than in the df2 scripting environment.