我使用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}
答案 0 :(得分:5)
在gremlin-server.yaml
中,您需要进行一些更改。
您需要更新主机。默认值为localhost
,这意味着您只能从本地客户端进行连接。如果要监听所有接口,则应使用机器的IP地址或0.0.0.0。
host: 0.0.0.0
您应该使用WebSocketChannelizer
代替HttpChannelizer
gremlin-javascript
,因为它是TinkerPop3 Gremlin服务器的WebSocket JavaScript客户端。
channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer