Saturday 8 April 2017

Having trouble writting remotely to Cassandra server from node.js

Environment: OS: Debian, Cassandra: 3.10, Node.js 7.5.0,cassandra-driver: 3.2.0

Error: (node:7484) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: All host(s) tried for query failed. First host tried, 192.168.10.151:9042: Error: connect ECONNREFUSED 192.168.10.151:9042. See innerErrors.(node:7484) DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Nodejs Code:

var express = require('express');
var router = express.Router();
var bodyParser = require('body-parser');
var fs = require('fs');
var cassandra = require('cassandra-driver');
var async = require('async');
var client = new cassandra.Client({contactPoints: ['192.168.10.151'], keyspace: 'users'});

router.post('/', function(req, res, next) {
    var query = 'INSERT INTO userAuth(email,password) VALUES(req.body.email,req.body.password)';
    client.execute(query);
    });

module.exports = router;

I am not sure what i am doing wrong.



via Iwin

No comments:

Post a Comment