Code Monkey home page Code Monkey logo

gremlin-javascript's Introduction

gremlin-javascript's People

Contributors

ctdio avatar dmill-bz avatar guyellis avatar jacobweyer avatar jamesfremen avatar jbmusso avatar princjef avatar vicneanschi avatar vivekr20 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

gremlin-javascript's Issues

g.addV doesn't work with the binding argument

Insert without the binding argument works:

var script = 'g.addV("name", "kelly")';
var query = client.stream(script);

But with the binding argument I get an error:

var script = 'g.addV(name)'
var bindings = {name: 'kelly'};
var query = client.stream(script, bindings);
      throw er; // Unhandled 'error' event
      ^

Error: Error: The provided key/value array length must be a multiple of two (Error 500)
    at MessageStream.<anonymous> (/home/oren/projects/titan/titan-gremlin-client/node_modules/gremlin-client/src/gremlinclient.js:264:26)
    at emitOne (events.js:77:13)
    at MessageStream.emit (events.js:169:7)
    at GremlinClient.handleMessage (/home/oren/projects/titan/titan-gremlin-client/node_modules/gremlin-client/src/gremlinclient.js:83:21)
    at WebSocket.onMessage (/home/oren/projects/titan/titan-gremlin-client/node_modules/gremlin-client/node_modules/ws/lib/WebSocket.js:418:14)
    at emitTwo (events.js:87:13)
    at WebSocket.emit (events.js:172:7)
    at Receiver.ontext (/home/oren/projects/titan/titan-gremlin-client/node_modules/gremlin-client/node_modules/ws/lib/WebSocket.js:816:10)
    at /home/oren/projects/titan/titan-gremlin-client/node_modules/gremlin-client/node_modules/ws/lib/Receiver.js:477:18
    at Receiver.applyExtensions (/home/oren/projects/titan/titan-gremlin-client/node_modules/gremlin-client/node_modules/ws/lib/Receiver.js:364:5)

Cannot read property 'messageStream' of undefined, and Invalid OpProcessor requested [null]

Hi,

I'm running a batch of traversals (about 50-60) and I'm getting the error below. Unfortunately, the error is not easy to reproduce but it does occur in the same module. Secondly, if I add console log messages or increase the debug levels, or step through the code, the error goes away. So, I'm limited on what I can provide to reproduce the problem. Any ideas on what it could be?

Thanks,
Dave

Log from the client:-

2016-11-21T07:00:24.857Z - error: uncaughtException: Cannot read property 'messageStream' of undefined date=Sun Nov 20 2016 23:00:24 GMT-0800 (Pacific Standard Time), pid=13136, uid=null, gid=null, cwd=D:\itc\development\itc\itc-dev\node_modules\applications\apps\my-home-space\init, execPath=D:\nodejs\node.exe, version=v6.6.0, argv=[D:\nodejs\node.exe, D:\itc\development\itc\itc-dev\node_modules\applications\apps\my-home-space\init\init-everything.js], rss=73846784, heapTotal=65933312, heapUsed=35439928, loadavg=[0, 0, 0], uptime=1050133.7672195 TypeError: Cannot read property 'messageStream' of undefined at GremlinClient.handleProtocolMessage (D:\itc\development\itc\node_modules\gremlin\lib\GremlinClient.js:153:51) at WebSocketGremlinConnection.<anonymous> (D:\itc\development\itc\node_modules\gremlin\lib\GremlinClient.js:120:23) at emitOne (events.js:96:13) at WebSocketGremlinConnection.emit (events.js:188:7) at WebSocketGremlinConnection.handleMessage (D:\itc\development\itc\node_modules\gremlin\lib\WebSocketGremlinConnection.js:69:12) at WebSocketGremlinConnection._this.ws.onmessage (D:\itc\development\itc\node_modules\gremlin\lib\WebSocketGremlinConnection.js:46:20) at WebSocket.onMessage (D:\itc\development\itc\node_modules\ws\lib\WebSocket.js:418:14) at emitTwo (events.js:106:13) at WebSocket.emit (events.js:191:7) at Receiver.onbinary (D:\itc\development\itc\node_modules\ws\lib\WebSocket.js:823:10)

Log from the Gremlin server:-

22:57:22 [WARN] AbstractGraphSONMessageSerializerV1d0.deserializeRequest:147 - Request [PooledUnsafeDirectByteBuf(ridx: 373, widx: 373, cap: 390)] could not be deserialized by org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0. 22:57:22 [WARN] OpSelectorHandler.decode:88 - Invalid OpProcessor requested [null] org.apache.tinkerpop.gremlin.server.op.OpProcessorException: Invalid OpProcessor requested [null] at org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler.decode(OpSelectorHandler.java:84) at org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler.decode(OpSelectorHandler.java:50) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler$1.channelRead(WebSocketServerProtocolHandler.java:146) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:244) at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308) at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294) at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846) at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131) at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511) at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468) at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382) at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354) at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111) at java.lang.Thread.run(Unknown Source)

Passing dates

What is the best way to pass a date to gremlin? When I try with new Date() or new Date().toISOString() I log the following error:

Value [2016-03-07T19:08:20.809Z] is not an instance of the expected data type for property key [lastSyncDate] and cannot be converted. Expected: class java.util.Date, found: class java.lang.String (Error 500)

Is it possible to cast to a java Date somehow?

Feature request: custom websocket path

Currently there is no ability to connect to websocket at some custom path like ws://myhost:80/websockets/test/ - it might be very useful in scenarios when Nginx websocket proxy is involved.

Currently there is dirty hack that allows to do this: specifying path as part of port parameter in createClient call like const client = Gremlin.createClient('80/websockets/test/', 'localhost');

I wonder if it's possible to rewrite url generation to support one additional parameter path so the call would be like const client = Gremlin.createClient(80, 'localhost', '/websockets/test/');

Empty array

Hello, the callback is not called when the response array is empty.

var client = gremlin.createClient();

client.execute('g.V().limit(0)', function(err, results) {
  console.log('hello');
});

No compatible version found: [email protected]

Doing an npm i on this project I got:

guy@MSI-GS60:~/source/gremlin-javascript$ npm i
npm WARN deprecated [email protected]: Full rewrite in 1.0. 0.x is deprecated.
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: [email protected]
npm ERR! Linux 3.16.0-67-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "i"
npm ERR! node v5.9.0
npm ERR! npm  v3.7.3

npm ERR! No compatible version found: [email protected]
npm ERR! Valid install targets:
npm ERR! 0.0.9
npm ERR! 
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /home/guy/source/gremlin-javascript/npm-debug.log

The pertinent info from the npm-debug.log is:

12013 verbose stack Error: No compatible version found: [email protected]
12013 verbose stack Valid install targets:
12013 verbose stack 0.0.9
12013 verbose stack
12013 verbose stack     at pickVersionFromRegistryDocument (/usr/local/lib/node_modules/npm/lib/fetch-package-metadata.js:156:16)
12013 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/iferr/index.js:13:50
12013 verbose stack     at /usr/local/lib/node_modules/npm/lib/utils/pulse-till-done.js:19:8
12013 verbose stack     at saved (/usr/local/lib/node_modules/npm/lib/cache/caching-client.js:168:7)
12013 verbose stack     at /usr/local/lib/node_modules/npm/node_modules/graceful-fs/polyfills.js:210:7
12013 verbose stack     at FSReqWrap.oncomplete (fs.js:82:15)
12014 verbose cwd /home/guy/source/gremlin-javascript

I'm guessing this is a Mac vs Linux thing?

My OS:

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 14.04.4 LTS
Release:    14.04
Codename:   trusty

Cannot read property 'messageStream' of undefined

UPDATE: The problem I'm seeing may be related to Issue #29 and possibly addressed in PR #31 (or at least provide a better/safer foundation for supporting what I'm trying to do).

I've created a NodeJs utility for uploading multiple files to a Neo4j database via Tinkerpop 3 (one request per file). Essentially, a vertex with a "Content" property is created that represents the file.

I've seen the error sometimes appear after uploading 800+ files but on this occasion it was after just 30 files i.e. doesn't appear to be overloading buffer maximums. I was able to remove all the other files and reproduce it with the one text file in question. The files are almost all ".js" text files so they are not large.

I read the contents of the file with:-

var contents = fs.readFileSync(sourceName, 'utf8');

The Gremlin script adds a vertex with a 'Content' property containing the contents of the file. When I submit the script using the gremlin client "execute" method I receive the following:-

TypeError: Cannot read property 'messageStream' of undefined
    at GremlinClient.handleProtocolMessage (d:\itc\development\itc\node_modules\gremlin\lib\GremlinClient.js:153:51)
    at WebSocketGremlinConnection.<anonymous> (d:\itc\development\itc\node_modules\gremlin\lib\GremlinClient.js:120:23)
    at emitOne (events.js:78:13)
    at WebSocketGremlinConnection.emit (events.js:170:7)
    at WebSocketGremlinConnection.handleMessage (d:\itc\development\itc\node_modules\gremlin\lib\WebSocketGremlinConnection.js:69:12)
    at WebSocket._EventEmitter.WebSocketGremlinConnection._this.ws.onmessage (d:\itc\development\itc\node_modules\gremlin\lib\WebSocketGremlinConnection.js:46:20)
    at WebSocket.onMessage (d:\itc\development\itc\node_modules\ws\lib\WebSocket.js:418:14)
    at emitTwo (events.js:88:13)
    at WebSocket.emit (events.js:173:7)
    at Receiver.onbinary (d:\itc\development\itc\node_modules\ws\lib\WebSocket.js:823:10)

I don't believe the problem is with the script since it can successfully complete for 1000s of transactions before seeing this error.

Here is my yaml file:-

threadPoolWorker: 2
gremlinPool: 8
scriptEvaluationTimeout: 30000
serializedResponseTimeout: 30000
channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer
graphs: {
  graph: conf/itc-neo4j.properties}
plugins:
  - tinkerpop.tinkergraph
scriptEngines: {
  gremlin-groovy: {
    imports: [java.lang.Math, com.itc.steps.*, com.itc.strategy.*, com.itc.traversal.*, com.itc.utils.*, com.itc.Constants],
    staticImports: [java.lang.Math.PI],
    scripts: [scripts/empty-sample.groovy]},
  nashorn: {
    imports: [java.lang.Math, com.itc.steps.*, com.itc.strategy.*, com.itc.traversal.*, com.itc.utils.*, com.itc.Constants],
    staticImports: [java.lang.Math.PI]}}
serializers:
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0 }                                             # application/vnd.gremlin-v1.0+gryo
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}   # application/vnd.gremlin-v1.0+gryo-stringd
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerGremlinV1d0 }                                  # application/vnd.gremlin-v1.0+json
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 }                                         # application/json
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: 8192000
maxAccumulationBufferComponents: 8192
resultIterationBatchSize: 64
writeBufferLowWaterMark: 65535
writeBufferHighWaterMark: 65536
ssl: {
  enabled: false}

On the server I'm seeing the error below. The "PooledUnsafeDirectByteBuf" tells me that the message is being submitted by the client in the wrong format:-

[WARN] AbstractGraphSONMessageSerializerV1d0 - Request [PooledUnsafeDirectByteBuf(ridx: 1054, widx: 1054, cap: 1071)] could not be deserialized by org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0.
1749352 [gremlin-server-worker-2] WARN org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0  - Request [PooledUnsafeDirectByteBuf(ridx: 1054, widx: 1054, cap: 1071)] could not be deserialized by org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0.
[WARN] OpSelectorHandler - Invalid OpProcessor requested [null]
org.apache.tinkerpop.gremlin.server.op.OpProcessorException: Invalid OpProcessor requested [null]
        at org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler.decode(OpSelectorHandler.java:84)
        at org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler.decode(OpSelectorHandler.java:50)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
        at io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler$1.channelRead(WebSocketServerProtocolHandler.java:146)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:244)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
        at java.lang.Thread.run(Thread.java:745)
1749357 [gremlin-server-worker-2] WARN org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler  - Invalid OpProcessor requested [null]
org.apache.tinkerpop.gremlin.server.op.OpProcessorException: Invalid OpProcessor requested [null]
        at org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler.decode(OpSelectorHandler.java:84)
        at org.apache.tinkerpop.gremlin.server.handler.OpSelectorHandler.decode(OpSelectorHandler.java:50)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:89)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
        at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:103)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
        at io.netty.handler.codec.http.websocketx.WebSocketServerProtocolHandler$1.channelRead(WebSocketServerProtocolHandler.java:146)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
        at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:244)
        at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:308)
        at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:294)
        at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:846)
        at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
        at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:511)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:468)
        at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:382)
        at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:354)
        at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:111)
        at java.lang.Thread.run(Thread.java:745)

I tried to attach the file causing the problem but the Github Issue page gave an error saying "we don't support that file type". This provides a hint that perhaps the mime type is defaulting to the wrong value causing the server to fail.

The file is the "AUTHORS" file (no suffix) from the NPM "Acorn" node module and simply contains:-

List of Acorn contributors. Updated before every release.

Adrian Rakovsky
Alistair Braidwood
Andres Suarez
Aparajita Fishman
Arian Stolwijk
Artem Govorov
Brandon Mills
Charles Hughes
Conrad Irwin
David Bonnet
Forbes Lindesay
Gilad Peleg
impinball
Ingvar Stepanyan
Jiaxing Wang
Johannes Herr
Jรผrg Lehni
keeyipchan
krator
Marijn Haverbeke
Martin Carlberg
Mathias Bynens
Mathieu 'p01' Henri
Max Schaefer
Max Zerzouri
Mihai Bazon
Mike Rennie
Nick Fitzgerald
Oskar Schรถldstrรถm
Paul Harper
Peter Rust
PlNG
r-e-d
Rich Harris
Sebastian McKenzie
zsjforcn

How to specify config for gremlin-client?

Another question rather than an issue; I'm not sure if it pertains to Gremlin in general or to gremlin-client so apologies if I'm posting in the wrong place.

I'd like to define a Geo index and use it from gremlin client; my setup is the stock 1.0.0-hadoop1 release. Starting the server with an empty db I execute the following in gremlin console:

// define a _geo property and index
graph = TitanFactory.open('conf/titan-cassandra-es.properties')
mgmt = graph.openManagement()
mgmt.makePropertyKey('_geo').dataType(Geoshape.class).cardinality(Cardinality.SINGLE).make()
l = mgmt.getPropertyKey('_geo')
mgmt.buildIndex('byGeo', Vertex.class).addKey(l).buildMixedIndex("search")
mgmt.commit()

// test
g = graph.traversal()
g.addVertex(label, 'AP', '_geo', Geoshape.point(45, 50))
g.addVertex(label, 'AP', '_geo', Geoshape.point(45, 55))
g.addVertex(label, 'AP', '_geo', Geoshape.point(45, 60))
g.V().has('_geo', geoWithin(Geoshape.circle(45, 50, 50)))

The geo query succeeds with no warnings so I assume the index was found.

With the server processes still running I wrap the test portion above into a mocha script and issue the same queries via gremlin-client, but I receive

Error: No signature of method: org.apache.tinkerpop.gremlin.process.traversal.dsl.graph.GraphTraversalSource.addVertex() is applicable for argument types: (org.apache.tinkerpop.gremlin.structure.T$1, java.lang.String, java.lang.String, com.thinkaurelius.titan.core.attribute.Geoshape) values: [label, AP, _geo, point[45.0,50.0]](Error 597)

I assume the problem is that my gremlin-server is not using the same graph as the gremlin console, so I update my gremlin-server.yaml to open the graph described by conf/titan-cassandra-es.properties and restart, but after doing this much my test doesn't log anything and doesn't return.

I guess I'm still not clear about the relationship between the moving parts :)

Help appreciated.

serialization error

var gremlin = require('gremlin-client');
var client = gremlin.createClient(8182, 'localhost');

var query = client.stream('g.addV("bela", "menere")');

query.on('data', function(result) {
  console.log('result', result);
});

query.on('end', function() {
  console.log("All results fetched");
});

script output:

events.js:141
      throw er; // Unhandled 'error' event
            ^
Error: Error: Error during serialization: (was java.lang.IllegalStateException) (through reference chain: java.util.ArrayList[0]->com.thinkaurelius.titan.graphdb.relations.RelationIdentifier["inVertexId"]) (Error 599)
    at MessageStream.<anonymous> (/home/oren/projects/titan/titan-test/node_modules/gremlin-client/src/gremlinclient.js:264:26)
    at emitOne (events.js:77:13)
    at MessageStream.emit (events.js:169:7)
    at GremlinClient.handleMessage (/home/oren/projects/titan/titan-test/node_modules/gremlin-client/src/gremlinclient.js:83:21)
    at WebSocket.onMessage (/home/oren/projects/titan/titan-test/node_modules/gremlin-client/node_modules/ws/lib/WebSocket.js:414:14)
    at emitTwo (events.js:87:13)
    at WebSocket.emit (events.js:172:7)
    at Receiver.ontext (/home/oren/projects/titan/titan-test/node_modules/gremlin-client/node_modules/ws/lib/WebSocket.js:797:10)
    at /home/oren/projects/titan/titan-test/node_modules/gremlin-client/node_modules/ws/lib/Receiver.js:473:18
    at Receiver.applyExtensions (/home/oren/projects/titan/titan-test/node_modules/gremlin-client/node_modules/ws/lib/Receiver.js:360:5)

server log:

titan_1         | 552629 [gremlin-server-worker-1] WARN  org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0  - Response [ResponseMessage{requestId=85e14a97-7bb7-4727-5ecb-50cde02ae446, status=ResponseStatus{code=SUCCESS, message='', attributes={}}, result=ResponseResult{data=[v[4216]], meta={}}}] could not be serialized by org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0.
titan_1         | 552631 [gremlin-server-worker-1] WARN  org.apache.tinkerpop.gremlin.server.handler.WsGremlinResponseEncoder  - The result [ResponseResult{data=[v[4216]], meta={}}] in the request 85e14a97-7bb7-4727-5ecb-50cde02ae446 could not be serialized and returned.
titan_1         | org.apache.tinkerpop.gremlin.driver.ser.SerializationException: com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.IllegalStateException) (through reference chain: java.util.ArrayList[0]->com.thinkaurelius.titan.graphdb.relations.RelationIdentifier["inVertexId"])
titan_1         |       at org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0.serializeResponseAsString(GraphSONMessageSerializerV1d0.java:101)
titan_1         |       at org.apache.tinkerpop.gremlin.server.handler.WsGremlinResponseEncoder.encode(WsGremlinResponseEncoder.java:79)
titan_1         |       at org.apache.tinkerpop.gremlin.server.handler.WsGremlinResponseEncoder.encode(WsGremlinResponseEncoder.java:45)
titan_1         |       at io.netty.handler.codec.MessageToMessageEncoder.write(MessageToMessageEncoder.java:89)
titan_1         |       at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:633)
titan_1         |       at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:691)
titan_1         |       at io.netty.channel.AbstractChannelHandlerContext.write(AbstractChannelHandlerContext.java:626)
titan_1         |       at org.apache.tinkerpop.gremlin.server.handler.IteratorHandler.write(IteratorHandler.java:119)
titan_1         |       at io.netty.channel.AbstractChannelHandlerContext.invokeWrite(AbstractChannelHandlerContext.java:633)
titan_1         |       at io.netty.channel.AbstractChannelHandlerContext.access$1900(AbstractChannelHandlerContext.java:32)
titan_1         |       at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.write(AbstractChannelHandlerContext.java:908)
titan_1         |       at io.netty.channel.AbstractChannelHandlerContext$WriteAndFlushTask.write(AbstractChannelHandlerContext.java:960)
titan_1         |       at io.netty.channel.AbstractChannelHandlerContext$AbstractWriteTask.run(AbstractChannelHandlerContext.java:893)
titan_1         |       at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:380)
titan_1         |       at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:357)
titan_1         |       at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:116)
titan_1         |       at java.lang.Thread.run(Thread.java:745)
titan_1         | Caused by: com.fasterxml.jackson.databind.JsonMappingException: (was java.lang.IllegalStateException) (through reference chain: java.util.ArrayList[0]->com.thinkaurelius.titan.graphdb.relations.RelationIdentifier["inVertexId"])
titan_1         |       at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:232)
titan_1         |       at com.fasterxml.jackson.databind.JsonMappingException.wrapWithPath(JsonMappingException.java:197)
titan_1         |       at com.fasterxml.jackson.databind.ser.std.StdSerializer.wrapAndThrow(StdSerializer.java:186)
titan_1         |       at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:640)
titan_1         |       at com.fasterxml.jackson.databind.ser.BeanSerializer.serialize(BeanSerializer.java:152)
titan_1         |       at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONUtil.writeWithType(GraphSONUtil.java:49)
titan_1         |       at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONSerializers.serializerVertexProperty(GraphSONSerializers.java:336)
titan_1         |       at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONSerializers.access$000(GraphSONSerializers.java:55)
titan_1         |       at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONSerializers$VertexJacksonSerializer.writeProperties(GraphSONSerializers.java:216)
titan_1         |       at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONSerializers$VertexJacksonSerializer.ser(GraphSONSerializers.java:193)
titan_1         |       at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONSerializers$VertexJacksonSerializer.serialize(GraphSONSerializers.java:175)
titan_1         |       at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONSerializers$VertexJacksonSerializer.serialize(GraphSONSerializers.java:163)
titan_1         |       at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:100)
titan_1         |       at com.fasterxml.jackson.databind.ser.impl.IndexedListSerializer.serializeContents(IndexedListSerializer.java:21)
titan_1         |       at com.fasterxml.jackson.databind.ser.std.AsArraySerializerBase.serialize(AsArraySerializerBase.java:183)
titan_1         |       at org.apache.tinkerpop.gremlin.structure.io.graphson.GraphSONUtil.writeWithType(GraphSONUtil.java:49)
titan_1         |       at org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0$ResponseMessageSerializer.ser(AbstractGraphSONMessageSerializerV1d0.java:235)
titan_1         |       at org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0$ResponseMessageSerializer.serialize(AbstractGraphSONMessageSerializerV1d
0.java:205)
titan_1         |       at org.apache.tinkerpop.gremlin.driver.ser.AbstractGraphSONMessageSerializerV1d0$ResponseMessageSerializer.serialize(AbstractGraphSONMessageSerializerV1d0.java:197)
titan_1         |       at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:114)
titan_1         |       at com.fasterxml.jackson.databind.ObjectMapper._configAndWriteValue(ObjectMapper.java:2811)
titan_1         |       at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:2268)
titan_1         |       at org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0.serializeResponseAsString(GraphSONMessageSerializerV1d0.java:98)
titan_1         |       ... 16 more
titan_1         | Caused by: java.lang.IllegalStateException
titan_1         |       at com.google.common.base.Preconditions.checkState(Preconditions.java:158)
titan_1         |       at com.thinkaurelius.titan.graphdb.relations.RelationIdentifier.getInVertexId(RelationIdentifier.java:69)
titan_1         |       at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
titan_1         |       at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
titan_1         |       at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
titan_1         |       at java.lang.reflect.Method.invoke(Method.java:497)
titan_1         |       at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.get(BeanPropertyWriter.java:726)
titan_1         |       at com.fasterxml.jackson.databind.ser.BeanPropertyWriter.serializeAsField(BeanPropertyWriter.java:506)
titan_1         |       at com.fasterxml.jackson.databind.ser.std.BeanSerializerBase.serializeFields(BeanSerializerBase.java:632)
titan_1         |       ... 35 more
cassandra_1     |  INFO 08:02:26,143 Enqueuing flush of Memtable-batchlog@934169300(513/5130 serialized/live bytes, 12 ops)
cassandra_1     |  INFO 08:02:26,145 Writing Memtable-batchlog@934169300(513/5130 serialized/live bytes, 12 ops)
cassandra_1     |  INFO 08:02:26,149 Completed flushing; nothing needed to be retained.  Commitlog position was ReplayPosition(segmentId=1441698771246, position=157250)

According to phani1kumar/docker-titan#4 (comment) there should be a way to pass serialization to the gremlin-client. any ideas how it is being done?

Vertex Properties not working

This one seems to come from the Gremlin server (no apparent response):

var client = gremlin.createClient();

client.execute('g.V().next().properties()', function(err, results) {
  console.log('hello');
});

I use .properties('a','b', ...) to filter the properties returned. It worked well until recently and still does on the gremlin console.

processor value is ignored when session is set to true

The processor value will be ignored in buildMessage when the client is initialized with the following config values:

var gClient = gremlin.createClient(8182, 'localhost',
        {
            session: true,
            processor: 'anything-other-than-session'
        }
    );

Examples seem out of date with current execute() argument list

After fixing the connection issue, examples still fail with this error:

TypeError: callback is not a function

Looking at the code for node-example.js, execute() is called with:

client.execute(script, function(err, res) {

However, the prototype for execute() is:

execute(script, bindings = {}, message = {}, ...args) {

Where the callback is either taken from args or from message (if message has type function).

I guess this could be fixed by adding an empty dict to the call in the example scripts (so that the callback becomes the 3rd argument) or, more elegantly, by adding a check for bindings as well as message:

   if (typeof message === 'function') {
      callback = message;
      message = {};
    }
    else if (typeof bindings === 'function') {
        callback = bindings;
        bindings = {};
    }

I'll be happy to submit a PR if that helps.

Add LICENSE.txt

It would be helpful if gremlin-client specified a license. It would be extra cool if that happened to be the Apache 2.0 license, but of course that is up to you :)

addE() syntax

hi..

I'm trying to add an edge to the graph, but the proper/best addE() usage is eluding me. Probably simple. I'm currently using:
g.V(${fromVertexId}).addE(${edgelbl}).to(${toVertexId})

gremlin.zip

How to use binding with addVertex

Hi,

Great work here. Thanks fro doing this.
I have a question on how to use binding with addVertex.

If I put in script without bindings (and execute with your client) like:

var searchScript = "graph.addVertex('name', 'Dean Kaplan')";

Result is something like I expect:

[{"id":8248,"label":"vertex","type":"vertex","properties":{"name":[{"id":"1zb-6d4-3yd","value":"Dean Kaplan"}]}}]

But if I use bindings:

pairs = "'name', 'Dean Kaplan'";
var searchScript = "graph.addVertex(x)";
return module.exports.execute(searchScript, {x:pairs}, callback);

I get:

[{"id":12360,"label":"'name', 'Dean Kaplan'","type":"vertex","properties":{}}]

puts parameter into label....something obvious I'm doing wrong?

Thanks in advance.

Dean

Update ws dependency to 1.x

When I try to run heavy loads (many queries consecutively or concurrently) using this library with node 6.6.0, I occasionally run into issues like this one that appear to come from the underlying websockets library. When I shrinkwrap and bump the version of ws up from 0.8.0 to 1.1.1 everything still appears to work for me and the intermittent errors go away.

Is there a reason to stay on ws 0.x or can it be bumped to 1.x? It would be nice to not have to force the version up with shrinkwrap.

I can also try pulling the repo, updating and testing with the new version of ws when I have some time. I assume this is what i need to run:

npm run build
npm run test:node

Use with gremlin-server-3.2

This is a question rather than an issue, but I'm not sure how to mark it as such.

I have been using gremlin-client with the titan-1.0.0.0-hadoop1 release, communicating through a standalone gremlin-server-3.2. I realize that this is not a supported configuration but it has been working well enough for a POC.

I'm wanting to migrate to a source build of titan with gremlin server 3.2, per https://groups.google.com/forum/#!topic/gremlin-users/ajs0C4-0vzY, but when I do so I lose the ability to use arrays as bound properties via gremlin client, in spite of the fact that they work in the gremlin console.
For example the following works in gremlin console but fails when issued via gremlin client using bound parameters.

// works in gremlin console
g.addV( "name","vn", "read",["p1"])

// works via gremlin client
g.addV( "name","vn", "read",["p1"])

// fails with bound parameter via gremlin client
g.addV( "name","vn", "read", read), {read:[ 'p1' ]}
=>
Error: Property value [[p1]] is of type class java.util.ArrayList is not supported (Error 500)

The query works via gremlin-client against my original titan-1.0.0-hadoop1 + gremlin-server-3.2 installation, so I'm wondering if the error with the custom build is some artifact of the build or if I am missing some gremlin server config or ?

Help appreciated.

Array property type?

When I add a property with an Array data type my callback returns err 'property value [[37.7, 23.9]] is of type class java.util.ArrayList is not supported (Error 500)'. Same result if it's inline or bound, ie

client.execute( 'g.addV( "name", name, "place", [37.7,23.9] )', {name:'Home'},..
client.execute( 'g.addV( "name", name, "place", place)', {name:'Home',place:[37.7,23.9]},..

Wondering if there is another syntax for arrays or am I missing some config or ?

Deserialization

Could it be possible to configure the way objects are serialized/deserialized when we request them from the server ?

client.execute not working with Tinkerpop Server 3.2.3โ€ฆ

When running either example code or npm run examples:node, the script seems to start fine and even connect to the socket (throws an error if the server is not running), but client.execute's callback never gets called.

Tinkerpop Server version is: 3.2.3 and started with: ./bin/gremlin-server.sh conf/gremlin-server-classic.yaml

Node version is: 7.0 (but also tried with v6.9.1: same results).

npm version is: 3.10.8

Connecting to the Tinkerpop Server with gremlin console or through the Python interface works fine.

No results when tree() step added to script

I have simplified a traversal to "g.V(1).out().tree()" and "g.V(1).out().tree().next()" and am not getting any results. There are no errors in the server log and I have verified that results are not being passed through the default 'executeHandler'. It does work if I remove the "tree()" step.

I'm not sure if I'm doing something wrong or it is a bug.

Serialization error

I am able to reproduce the last issue opened about the serialization error. I get the following error when trying to add a vertex:

Error: Error during serialization: (was java.lang.IllegalStateException) (through reference chain: java.util.ArrayList[0]->com.thinkaurelius.titan.graphdb.relations.RelationIdenti
fier["inVertexId"]) (Error 599)
at GremlinClient.handleProtocolMessage (/Users/joe/titan/titan/node_modules/gremlin/lib/GremlinClient.js:174:39)
at WebSocketGremlinConnection. (/Users/joe/titan/titan/node_modules/gremlin/lib/GremlinClient.js:120:23)
at emitOne (events.js:96:13)
at WebSocketGremlinConnection.emit (events.js:188:7)
at WebSocketGremlinConnection.handleMessage (/Users/joe/titan/titan/node_modules/gremlin/lib/WebSocketGremlinConnection.js:69:12)
at WebSocketGremlinConnection._this.ws.onmessage (/Users/joe/titan/titan/node_modules/gremlin/lib/WebSocketGremlinConnection.js:46:20)
at WebSocket.onMessage (/Users/joe/titan/titan/node_modules/ws/lib/WebSocket.js:418:14)
at emitTwo (events.js:106:13)
at WebSocket.emit (events.js:191:7)

This is what my gremlin-server.yaml looks like:

host: 0.0.0.0
port: 8182
threadPoolWorker: 1
gremlinPool: 8
scriptEvaluationTimeout: 30000
serializedResponseTimeout: 30000
channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer
graphs: {
  graph: conf/gremlin-server/titan-cassandra-es-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 }
  - { className: org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 }
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}

Gremlin Native JavaScript Stringification

Do you think that there's any value in creating a JavaScript Native API for Gremlin? Under the hood this would do a stringification of the fluent commands to generate the code to execute. So the quick start would look something like this:

import { createGraph } from 'gremlin';

const g = createGraph();

g.V().has('name', 'Alice').execute((err, results) => {
  if (err) {
    return console.error(err)
  }

  console.log(results);
});

// Or with "sugar" any method that accepted a variable number of pairs of
// parameters could also accept an object a la:
const q = {name: 'Alice'};
g.V().has(q).execute((err, results) => {
...

WDYT?

Adding Data to Gremlin?

This is great library.

Is there anyway to add data to Gremlin using this library?

How to execute queries with transactions where we have to create a Vertex First and then pass the reference of the Vertex to create an Edge ?

Custom serializer issue

Hey JB,

I'm trying to implement gremlin-javascript with a custom server side serializer. For the client this should be pretty transparent as the response message structure doesn't change (only the data being sent back). It however requires that the request message sent from the client have a different mimetype (application/gremlinbin). The following does not seem to work:

Gremlin.createClient(8182, "localhost", {accept:"application/gremlinbin"});

It's pretty easy to test manually as gremlin-server will complain about having to use GraphSONMessageSerializerV1d0 by default because it can't find the serializer associated with that mimetype.

Any hint as to what would need to be fixed for this? I'm a little lost running through your code but with some guidance I could probably pull a fix.

Examples aren't working

When running the examples I get:

guy@MSI-GS60:~/source/gremlin-javascript/examples$ node node-example
module.js:341
    throw err;
    ^

Error: Cannot find module '../'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at Object.<anonymous> (/home/guy/source/gremlin-javascript/examples/node-example.js:1:77)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)
    at Function.Module.runMain (module.js:447:10)

I created a PR to discuss this and then realized that I should have created an issue first. So this is that issue. Here is the PR: #39

Ended commands not removed from the pending command list

gremlinclient internal command list is not cleaned properly for commands in error or with no content.
The commands are removed from the list only if the server HTTP return code is 200.
In all the others cases the commands are kept
It causes new error events on commands already processed during disconnection.
I may be wrong but I also would delete the commands for code 204 and errors.

Add client.close() method

Aliasing client.ws.close() (to close the client when done with discussing with the API)

Unrelated but I haven't found where the API is documented (at least methods list). Is there such a place?

npm failed

I'm trying to reinstall gremlin-client in a new location, but getting errors. Anything obvious I'm doing wrong (there has been an upgrade of node and npm versions)?

vagrant@vagrant-ubuntu-precise-64:/isdb/src/isdb-serverless/gremlin$ sudo npm install gremlin --save
npm ERR! Linux 3.2.0-89-virtual
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "gremlin" "--save"
npm ERR! node v4.0.0
npm ERR! npm v3.7.2
npm ERR! path /isdb/src/isdb-serverless/gremlin/node_modules/node-uuid/bin/uuid
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall chmod

npm ERR! enoent ENOENT: no such file or directory, chmod '/isdb/src/isdb-serverless/gremlin/node_modules/node-uuid/bin/uuid'
npm ERR! enoent ENOENT: no such file or directory, chmod '/isdb/src/isdb-serverless/gremlin/node_modules/node-uuid/bin/uuid'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR! /isdb/src/isdb-serverless/gremlin/npm-debug.log

Regards,

Dean

Error when trying to use the library

var gremlin = require('gremlin-client');
var client = gremlin.createClient(8182, 'localhost');

var query = client.stream('g.V()');

query.on('data', function(result) {
  // Handle first vertex
  console.log(result);
});

query.on('end', function() {
  console.log("All results fetched");
});
node index.js
module.js:338
    throw err;
              ^
              Error: Cannot find module 'lodash.isArray'
                  at Function.Module._resolveFilename (module.js:336:15)
      at Function.Module._load (module.js:286:25)
      at Module.require (module.js:365:17)
      at require (module.js:384:17)
      at Object.<anonymous> (/tmp/foo/node_modules/gremlin-client/src/executehandler.js:4:12)
      at Module._compile (module.js:430:26)
      at Object.Module._extensions..js (module.js:448:10)
      at Module.load (module.js:355:32)
      at Function.Module._load (module.js:310:12)
      at Module.require (module.js:365:17)

Id bound parameter not working

// Doesn't work
client.execute("g.V(id).valueMap()", {id:53408}, function(err, results) {
console.log(results);
next();
});

// Works
client.execute("g.V(53408).valueMap()", function(err, results) {
console.log(results);
next();
});

'Error: socket hang up' when trying to use the library

Steps to reproduce:

git clone https://github.com/oren/titan.git
cd titan
docker-compose up
npm install
node get-all.js

Error:
{ [Error: socket hang up]
  code: 'ECONNRESET',
  target:
   { domain: null,
     _events:
      { open: [Object],
        error: [Object],
        message: [Object],
        close: [Object] },
     _eventsCount: 4,
     _maxListeners: undefined,
     _socket: null,
     _ultron: null,
     _closeReceived: false,
     bytesReceived: 0,
     readyState: 0,
     supports: { binary: true },
     extensions: {},
     _isServer: false,
     url: 'ws://localhost:8182',
     protocolVersion: 13
  }
}

by the way, gremlin console seems to be fine:

bin/gremlin

plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
07:48:40 INFO  org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph  - HADOOP_GREMLIN_LIBS is set to: /opt/titan-0.9.0-M2-hadoop1/bin/../lib
plugin activated: tinkerpop.hadoop
plugin activated: tinkerpop.tinkergraph
plugin activated: aurelius.titan
gremlin>  :remote connect tinkerpop.server conf/remote.yaml
==>Connected - localhost/127.0.0.1:8182
gremlin> :> graph.addVertex("name", "stephen")
==>v[4160]
gremlin> :> g.V().values('name')
==>stephen
gremlin>

I also posted it on the mailing list.

roblem using gremlin npm when running the query graph.indexQuery("searchPropIndex", "v.searchProp:Marko").vertices()*.getElemet()

The query does not work when using titan 1.0.0 gremlin 3.0.1. I tried to convert the elements to vertexes but it did not work. I tired to use iterator() but I could not get all the vertexes only the first .

then I did g.V( graph.indexQuery(......).toArray()) , it works , but when the array is empty it turns to be g.V() and it returns all vertexes insted of empty result.

I do not want to use two queries in order to run indexQuery (Im using elastic search)/

Graph traversal object "g" initialization

When using the client under node.js in session mode over the internet (forwarded through NAT), the gremlin client will not return stream results without creating the "g" graph traversal object before other queries. Specifically, for a cassandra and elasticsearch setup, I had to run:

client.stream('graph = TitanFactory.open('conf/titan-cassandra-es.properties');g = graph.traversal()');

After doing so, I was able to run queries as normal. It may just be my specific setup, however it seems logical that the server would have no idea what "g" is without it being defined beforehand. If this is indeed a bug, I would recommend adding the above query before all other queries are run.

Invalid OpProcessor requested [null]

This is probably not the most relevant issue (i'm not using this library) but I can't find anything relevant on the Tinkerpop3 JIRA or Titan 1.x docs or github generally.. So you'll have to forgive me if this is out of place.

I'm having an immense amount of trouble communicating with my gremlin / titan server via websockets using C++. Logically this shouldn't be too hard, though I think the API is changing so drastically that none of the documentation I find has an accurate explanation of the message structure / format.

I'm using the easywsclient library, and an example of my code (and format) is as follows:

std::unique_ptr ws(WebSocket::from_url("ws://SERVER:8182/"));

string command = "\"[1,2,3,4]\"";
string mime = "\"application/json\"";
string language = "\"gremlin-groovy\"";
string session = "\"\"";
string bindings = "\"\"";
string rebindings = "\"\"";
string op = "\"eval\"";
string processor = "\"org.apache.tinkerpop.gremlin.server.op.session.SessionOpProcessor\"";
string accept = "\"application/json\"";
string executeHandler;
string request = "\"655BD810-B41E-429D-B78F-3CC5F3B8E9BA\"";

string msg = mime + "|-{" +
    "\"requestId\": " + request + "," +
    "\"op\": " + op + ","  +
    "\"processor\": " + processor + "," +
    "\"args\": {"  +
        "\"gremlin\": " + command + "," +
        "\"bindings\": " + bindings + "," +
        "\"language\": " + language + "," +
        "\"rebindings\": " + rebindings +
    "}" +
"}";


ws->send(msg);
//** then ws->poll and ws->dispatch to retrieve the response

To which my erroneous response is:

{"requestId":null,"status":{"message":"","code":499,"attributes":{}},"result":{"data":"Invalid OpProcessor requested [null]","meta":{}}}

I cannot seem to find any variation of op or processor (I have tried blank) that returns anything but the above.

Any help or tips would be greatly appreciated!

Per-message processor ignored when using sessions

In this example the processor will be ignored.

var gremlinClient = gremlin.createClient(8182, 'localhost', {session: true});
gremlinClient.execute(script, null, {processor: 'willBeIgnored'}, callback);

The bug occurs on the following line, where the session processor is used despite the fact that the message.processor is already set.

https://github.com/jbmusso/gremlin-client/blob/develop/src/gremlinclient.js#L195

I believe it should be something more like this:

command.message.processor = (message.processor || (this.options.processor || 'session'));

hang during test

hi..

I am using Jest to unit test and unfortunately it hangs if I instantiate the client. Digging into it, but if you have any insight it would be appreciated.

The setup to reproduce, which is quite minimal, is attached. Uncomment the section in src/ GremlinClient.js to reproduce.
gremlin.zip

thanks

Traversal object 'g' not initialized

I'm not sure if this is related to gremlin-javascript, but this issue started right after I updated to the latest version. g and graph are no longer available to my calls by default. I'm still able to connect, but need to fully instantiate these objects on each call now:

g = graph.traversal(standard());
graph = TitanFactory.open("conf/gremlin-server/dynamodb.properties");

I found issue #21, but so far haven't been able to fix the problem. The contents of gremlin-server.yaml are attached, but I've made no recent updates to it.

I will note that when operating on the console (bin/gremlin.sh), I've always needed to manually instantiate these objects. However up until recently gremlin-javascriptalways provided a client with g and graph available. I'm not sure what changed to cause this.

Gremlin version:

gremlin> Gremlin.version()
==>3.0.1-incubating

Output when starting gremlin.sh:

$ bin/gremlin.sh

         \,,,/
         (o o)
-----oOOo-(3)-oOOo-----
plugin activated: aurelius.titan
plugin activated: tinkerpop.server
plugin activated: tinkerpop.utilities
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/packages/dynamodb-titan100-storage-backend-1.0.0-hadoop1/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/packages/dynamodb-titan100-storage-backend-1.0.0-hadoop1/lib/logback-classic-1.1.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/packages/dynamodb-titan100-storage-backend-1.0.0-hadoop1/ext/dynamodb-titan100-storage-backend/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
14:14:10 INFO  org.apache.tinkerpop.gremlin.hadoop.structure.HadoopGraph  - HADOOP_GREMLIN_LIBS is set to: /usr/local/packages/dynamodb-titan100-storage-backend-1.0.0-hadoop1/lib
plugin activated: tinkerpop.hadoop
plugin activated: tinkerpop.tinkergraph
gremlin>

gremlin-server.yaml:

# Copyright 2014-2015 Amazon.com, Inc. or its affiliates. All Rights Reserved.
# Portions copyright Titan: Distributed Graph Database - Copyright 2012 and onwards Aurelius.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://aws.amazon.com/apache2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# This file was adapted from the following file:
# https://github.com/thinkaurelius/titan/blob/1.0.0/titan-dist/src/assembly/static/conf/gremlin-server/gremlin-server.yaml
#
host: 0.0.0.0
port: 8182
threadPoolWorker: 1
gremlinPool: 8
scriptEvaluationTimeout: 30000
serializedResponseTimeout: 30000
channelizer: org.apache.tinkerpop.gremlin.server.channel.WebSocketChannelizer
graphs: {
  graph: conf/gremlin-server/dynamodb.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: false, interval: 180000},
  csvReporter: {enabled: false, interval: 180000, fileName: /tmp/gremlin-server-metrics.csv},
  jmxReporter: {enabled: false},
  slf4jReporter: {enabled: false, 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}

'messageStream' of undefined with titan error 599

Here an error to manage.

this error come when titan return an error 599.

Erreur of titan :
[Error: Error during serialization: GC overhead limit exceeded (Error 599)]

Error of gremlin-javascript :
C:\Users\b03614\Documents\my-contacts-ui\app\node_modules\gremlin\lib\GremlinClient.js:153
var messageStream = this.commands[requestId].messageStream;
^

TypeError: Cannot read property 'messageStream' of undefined
at GremlinClient.handleProtocolMessage (C:\Users\b03614\Documents\my-contacts-ui\app\node_modules\gremlin\lib\Gremli
nClient.js:153:51)
at WebSocketGremlinConnection. (C:\Users\b03614\Documents\my-contacts-ui\app\node_modules\gremlin\lib\Gre
mlinClient.js:120:23)
at emitOne (events.js:77:13)
at WebSocketGremlinConnection.emit (events.js:169:7)
at WebSocketGremlinConnection.handleMessage (C:\Users\b03614\Documents\my-contacts-ui\app\node_modules\gremlin\lib\W
ebSocketGremlinConnection.js:69:12)
at WebSocketGremlinConnection._this.ws.onmessage (C:\Users\b03614\Documents\my-contacts-ui\app\node_modules\gremlin
lib\WebSocketGremlinConnection.js:46:20)
at WebSocket.onMessage (C:\Users\b03614\Documents\my-contacts-ui\app\node_modules\gremlin\node_modules\ws\lib\WebSoc
ket.js:418:14)
at emitTwo (events.js:87:13)
at WebSocket.emit (events.js:172:7)
at Receiver.onbinary (C:\Users\b03614\Documents\my-contacts-ui\app\node_modules\gremlin\node_modules\ws\lib\WebSocke
t.js:823:10)

unsure how to set the label on a vertex

hi..

I am trying to set the label on a vertex using addV(), but perhaps have the syntax wrong or maybe I should be using a property like 'name'. The intent is to use a label prefix, such as 'SYS_', to separate the vertices into categories so that access permissions can be easily applied. Probably I've missed some docs. Any help would be appreciated.

The setup to reproduce, which is quite minimal, is attached. The README provides steps.
gremlin.zip

thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.