1

I'm playing with the last version of DSE Enterprise. I'm interested in the graph features. I currently have one project running on Titan the open source graph database that inspired DSE Graph, and I'm trying to evaluate DSE Graph as a replacement database, since Titan is missing many administration and operation features.

My problem is the following:

I have a strange behavior while trying to execute graph queries on a datastax cluster using the nodejs driver. The query is working (I can add or delete vertices), but on the client side (nodejs driver) I get always a connection timeout error, after 5 to 7 seconds, like this:

 {
    "statusCode": 200,
    "body": {
        "info": {
            "queriedHost": "xx.xx.xx.xx:9042",
            "triedHosts": {
                "xx.xx.xx.xx:9042": {
                    "message": "Connection timeout",
                    "info": "Cassandra Driver Error"
                }
            },
            "achievedConsistency": 10
        },
        "length": 1,
        "pageState": null
    }
}

When I look at datastax studio, my queries are working though. I can see the newly added vertices...

Here is the code used to call dse graph:

'use strict';

const dse = require('dse-driver');
const dseGraph = require('dse-graph');
const client = new dse.Client({
  contactPoints: ['xx.xx.xx.xx'] ,
  protocolOptions: {port: 9042},
  authProvider: new     dse.auth.DsePlainTextAuthProvider("xxx","xxx"),
  graphOptions: { name: 'test' }
});


module.exports.create = (event, context, callback) => {
  let response = {
    statusCode: 200
  };
  client.executeGraph("graph.addVertex(label,'user','email','c@b');").then(function(users) {
    response.body=users;
    client.shutdown();
    callback(null, response);
  }).catch(function(err) {    
    response.statusCode=400;
    response.body=err;
    client.shutdown();
    callback(null, response);
  });
};

May be the problem is in my cluster configuration?

Here is my topology:

  • One cluster
    • 3 datacenters
    • 1 datacenter for the graph, with 2 nodes
    • 1 datacenter for search, with 1 node
    • 1 datacenter for analytics, with 1 node

All settings are defaults ones. I've installed the cluster through OpsCenter, and all my nodes are ec2 instances (m4.xlarge).

Do you have any idea why the queries are working, but I get this strange message in the success callback?

Regards,

Toufic Zayed

Toufic Zayed
  • 55
  • 1
  • 9

2 Answers2

0

As stated in the docs, you should not call shutdown after each query is executed.

Normally you should use one Client instance per application. You should share that instance between modules within your application.

You should only call client.shutdown() once in your application’s lifetime, normally when you shutdown your application.

jorgebg
  • 6,560
  • 1
  • 22
  • 31
0

thanks to Jorge help, I added this line to log all the events received by the driver:

client.on('log', console.log)

I noticed in the logs that while I called the public address of my EC2 server (since my client is outside my VPC), the node tried to communicate using their private interface between them. And the mix of public and private address caused the problem.

Here is what I did, it solved the problem, but I don't know if it's the right answer.

I modified the cassandra.yaml file on each nodes, and I set the broadcast_rpc_address to the public address of each instance.

Now my queries are working.

The only remaining question is: is there a better way to handle a mix of public and private IP using Cassandra?

Am I doing something wrong by setting the broadcast_rpc_address to the public IP of the EC2 instance?

Toufic Zayed
  • 55
  • 1
  • 9
  • A quick comment on the status of the last question: I reverted back the cassandra.yaml configuration to the private address of the instances. I connect to these instances from outside through a aws lambda function. For local testing I just built a VPN inside my AWS VPC, so that my development desktop can connect to my cassandra instances in the same network without issues regarding the firewall rules. So I have best of both world. – Toufic Zayed Mar 31 '17 at 13:00