2

我使用gremlin-javascript模块来访问远程 gremlin 服务器。我在 app.js 中的代码:

var gremlin = require('gremlin-client');
var client = gremlin.createClient(8182, 'localhost');
var query = client.stream('g.V()');
query.on('data', function(result) {
  console.log(result);
});
query.on('end', function() {
  console.log("All results fetched");
});

这工作正常,所有查询都得到执行。但是当我用我的远程服务器地址 - cbtitan.cloudapp.net 替换“localhost”时,它会返回 ECONNREFUSED 错误。

我应该改变/做什么来连接到那个远程服务器?或者我应该更改该远程服务器中的任何配置吗?我被这个问题严重卡住了,请帮帮我。提前致谢。

gremlin-server.yaml

host: localhost
port: 8182
threadPoolWorker: 1
gremlinPool: 8
scriptEvaluationTimeout: 30000
serializedResponseTimeout: 30000
channelizer: org.apache.tinkerpop.gremlin.server.channel.HttpChannelizer
graphs: {
  graph: conf/gremlin-server/titan-berkeleyje-server.properties}
plugins:
  - aurelius.titan
scriptEngines: {
  gremlin-groovy: {
    imports: [java.lang.Math],
    staticImports: [java.lang.Math.PI],
    scripts: [scripts/empty-sample.groovy]},
  nashorn: {
      imports: [java.lang.Math],
      staticImports: [java.lang.Math.PI]}}
serializers:
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { useMapperFromGraph: graph }}
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0, config: { useMapperFromGraph: graph }}
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0, config: { useMapperFromGraph: graph }}
processors:
  - { className: org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor, config: { sessionTimeout: 28800000 }}
metrics: {
  consoleReporter: {enabled: true, interval: 180000},
  csvReporter: {enabled: true, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv},
  jmxReporter: {enabled: true},
  slf4jReporter: {enabled: true, interval: 180000},
  gangliaReporter: {enabled: false, interval: 180000, addressingMode: MULTICAST},
  graphiteReporter: {enabled: false, interval: 180000}}
threadPoolBoss: 1
maxInitialLineLength: 4096
maxHeaderSize: 8192
maxChunkSize: 8192
maxContentLength: 65536
maxAccumulationBufferComponents: 1024
resultIterationBatchSize: 64
writeBufferHighWaterMark: 32768
writeBufferHighWaterMark: 65536
ssl: {
enabled: false}
4

1 回答 1

5

在 中gremlin-server.yaml,您需要进行一些更改。

您需要更新主机。默认值为localhost,这意味着您只能从本地客户端连接。如果您想监听所有接口,您应该使用机器的 IP 地址或 0.0.0.0。

host: 0.0.0.0

您应该使用WebSocketChannelizer而不是HttpChannelizerwith,gremlin-javascript因为它是 TinkerPop3 Gremlin Server 的 WebSocket JavaScript 客户端。

channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer
于 2015-11-12T18:17:38.203 回答