如何使用 Gremlin 配置 Cassandra db 进行远程连接?不工作



我在Node Js中使用Cassandra DB,DSE graph,gremlin query。我能够在本地主机中获取值并访问数据库。每当我尝试连接到远程服务器(例如 http://remoteservercassandra.in)时都无法连接。如何连接到远程服务器?

我的代码是

var dse = require('dse-driver');
var client = new dse.Client({
   contactPoints: ['127.0.0.1'],
    authProvider: new dse.auth.DsePlainTextAuthProvider('username','password'),
   protocolOptions: {
     port: 9042
   },
   graphOptions: {
    name: 'mygraphname'
   }
});

当我尝试它时出现此错误

{
    "innerErrors": null,
    "info": "Represents an error when a query cannot be performed because no host is available or could be reached by the driver.",
    "message": "No host could be resolved"
}

如果我尝试连接远程服务器 URL(例如 http://remoteservercassandra.in),则会收到此错误。

var dse = require('dse-driver');
var client = new dse.Client({
   contactPoints: ['remoteservercassandra.in'],
    authProvider: new dse.auth.DsePlainTextAuthProvider('username','password'),
   protocolOptions: {
     port: 9042
   },
   graphOptions: {
    name: 'mygraphname'
   }
});

我收到此错误。

{
    "innerErrors": {
        "12.234.78.134:9042": { // based on host name this IP address
            "code": "ECONNREFUSED",
            "errno": "ECONNREFUSED",
            "syscall": "connect",
            "address": "12.234.78.134",
            "port": 9042
        }
    },
    "info": "Represents an error when a query cannot be performed because no host is available or could be reached by the driver.",
    "message": "All host(s) tried for query failed. First host tried, 12.234.78.134:9042: Error: connect ECONNREFUSED 12.234.78.134:9042. See innerErrors."
}

如何解决此错误以及如何连接到远程服务器?

确认远程服务器正在运行并侦听正确的接口:

lsof -i:9042

乍一看,这似乎是一个RPC_ADRESS问题。

相关内容

最新更新