using Node.js npm package version 3.3.2

566 views
Skip to first unread message

Noam Gal

unread,
Apr 25, 2018, 3:13:19 PM4/25/18
to Gremlin-users
Hello.

I've been using version 2.7.0 of your package, and am able to connect to CosmosDB gremlin server successfully. My code was

const client = gremlin.createClient(
443,
`${subDomain}.gremlin.cosmosdb.azure.com`,
{
session: true,
ssl: true,
user,
password,
},
);

and afterwards I'd just use client.execute to run my queries.

Today I tried upgrading to the latest 3.3.2 version of the same package, and there are a ton of breaking changes, with 0 documentation on how to actually use the package. All I could find was a reference to here. Those two paragraphs don't really explain how to use the updated version, and they also contain several code errors.
  1. Are there any detailed reference documents for this library?
  2. How can I connect to my CosmosDB using the new client?
  3. How should I send in the user and password fields?
  4. Should I use RemoteConnection, or some other class or option?
  5. Is there any way to send the Gremlin queries as strings, like before? Or do I have to use it in plain javascript instead
Thank you for your work on Gremlin/tinkerpop and the client library. I hope you can assist me with those questions.

 Noam Gal.

Stephen Mallette

unread,
Apr 25, 2018, 3:58:17 PM4/25/18
to Gremlin-users
2.7.0 was not an official Apache TinkerPop package. TinkerPop contributor, The Baptist, was the maintainer of that library at 2.7.0 and was nice enough to turn over 


to the community once we were ready with the official gremlin-javascript GLV for 3.2.8/3.3.2. That, of course, brought the major breaking changes you're seeing. The Baptist goes into more detail on that here:


There is no more documentation at this point than what you came across I'm afraid, but, on the other hand, that's really most of what you need to know:

const graph = new Graph();
const g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin'));

You now have "g", a GraphTraversalSource, and thus start writing Gremlin - no more scripts embedded as strings in your code!  The downside for you is that this doesn't work with CosmosDB yet. GLVs submit their requests in the form of bytecode, something I've heard CosmosDB is working on supporting. So....you would still need to submit scripts and, again, not explained in our docs, so not helpful. Since you are using CosmosDB, I think that I would recommend that you stay on 2.7.0 until bytecode is supported. Not sure if someone with more knowledge on then internals of gremlin-javascript will have more to say on the matter - perhaps you will get more/different advice from them.

Sorry for any confusion. We tried to get the word out about the NPM change as best we could....

--
You received this message because you are subscribed to the Google Groups "Gremlin-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gremlin-users/a6396282-2988-47ee-a811-097ba9198224%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Aaron Wood

unread,
Apr 25, 2018, 9:02:00 PM4/25/18
to Gremlin-users
I don't really understand the docs here either. The docs are missing an example of importing the module + using the import. Here's what I think it should be when you import:

const gremlin = require("gremlin");

const graph = new gremlin.structure.Graph();
const g = graph.traversal().withRemote(new gremlin.driver.RemoteConnection('ws://localhost:8182/gremlin'));
g.V().toList().then(function(data) {
console.log(data)
}).catch(function(err) {
console.log(err)
})


If you do it the way the docs state then it's assuming that Graph and DriverRemoteConnection are both globally available in the runtime. Even with running the above code I still hit errors about submit not being implemented:

Error: submit() was not implemented

    at RemoteConnection.submit (/Users/woodaaron/Code/src/api-gw/node_modules/gremlin/lib/driver/remote-connection.js:39:11)

    at RemoteStrategy.apply (/Users/woodaaron/Code/src/api-gw/node_modules/gremlin/lib/driver/remote-connection.js:66:28)

    at promise.then (/Users/woodaaron/Code/src/api-gw/node_modules/gremlin/lib/process/traversal-strategy.js:55:42)

    at <anonymous>

    at process._tickCallback (internal/process/next_tick.js:182:7)

    at Function.Module.runMain (internal/modules/cjs/loader.js:697:11)

    at startup (internal/bootstrap/node.js:201:19)

    at bootstrapNodeJSCore (internal/bootstrap/node.js:516:3)


Is there something I'm missing here? Looking at remote-connection.js in the gremlin module that's obtained from npm install gremlin shows that sumbit() just throws that error and does nothing else:

class RemoteConnection {
constructor(url) {
this.url = url;
}

/**
* @abstract
* @param {Bytecode} bytecode
* @returns {Promise}
*/
submit(bytecode) {
throw new Error('submit() was not implemented');
};
}
To unsubscribe from this group and stop receiving emails from it, send an email to gremlin-user...@googlegroups.com.

Aaron Wood

unread,
Apr 25, 2018, 9:26:10 PM4/25/18
to Gremlin-users
It looks like I should be using new gremlin.driver.DriverRemoteConnection('ws://localhost:8182/gremlin')
but I don't see this exposed anywhere in the module. I temporarily modified index.js in the module to have this:

var dr = require('./lib/driver/driver-remote-connection');
module.exports = {
driver: {
DriverRemoteConnection: dr,
...

and now the library throws errors about an invalid OpProcessor being used:

Error: Server error (no request information): Invalid OpProcessor requested [null] (499)

    at Object.keys.forEach.requestId (/Users/woodaaron/Code/src/api-gw/node_modules/gremlin/lib/driver/driver-remote-connection.js:137:15)

    at Array.forEach (<anonymous>)

    at DriverRemoteConnection._handleMessage (/Users/woodaaron/Code/src/api-gw/node_modules/gremlin/lib/driver/driver-remote-connection.js:132:45)

    at WebSocket.DriverRemoteConnection._ws.on.data (/Users/woodaaron/Code/src/api-gw/node_modules/gremlin/lib/driver/driver-remote-connection.js:68:41)

    at WebSocket.emit (events.js:180:13)

    at Receiver._receiver.onmessage (/Users/woodaaron/Code/src/api-gw/node_modules/gremlin/node_modules/ws/lib/WebSocket.js:141:47)

    at Receiver.dataMessage (/Users/woodaaron/Code/src/api-gw/node_modules/gremlin/node_modules/ws/lib/Receiver.js:380:14)

    at Receiver.getData (/Users/woodaaron/Code/src/api-gw/node_modules/gremlin/node_modules/ws/lib/Receiver.js:330:12)

    at Receiver.startLoop (/Users/woodaaron/Code/src/api-gw/node_modules/gremlin/node_modules/ws/lib/Receiver.js:165:16)

    at Receiver.add (/Users/woodaaron/Code/src/api-gw/node_modules/gremlin/node_modules/ws/lib/Receiver.js:139:10)


I am really confused about what is expected of consumers of this library. 

Aaron Wood

unread,
Apr 26, 2018, 2:18:46 AM4/26/18
to Gremlin-users

Timothy Dalbey

unread,
Jul 12, 2018, 9:29:55 PM7/12/18
to Gremlin-users
Is there a resolution to this?  I'm getting the exact same behavior as describ

Stephen Mallette

unread,
Jul 13, 2018, 11:03:05 AM7/13/18
to Gremlin-users
Does 3.2.9/3.3.3 not resolve that?

matt....@globesbusinessenterprises.com

unread,
Jul 14, 2018, 3:35:08 AM7/14/18
to Gremlin-users
3.2.9/3.3.3 does fix the issue. Here's the code I've been using to connect to a local GS instance.

const Gremlin = require('gremlin')
const connection = new Gremlin.driver.DriverRemoteConnection(`ws://${process.env.DOCDB_SERVER}:${process.env.DOCDB_SERVER_PORT}/gremlin`)
const graph = new Gremlin.structure.Graph()
const g = graph.traversal().withRemote(connection)

Timothy Dalbey

unread,
Jul 16, 2018, 1:59:52 PM7/16/18
to Gremlin-users
I've tried this in a variety of ways and I keep getting the same thing.

[WARN] WsGremlinBinaryRequestDecoder - Gremlin Server is not configured with a serializer for the requested mime type [application/vnd.gremlin-v3.0+json] - using org.apache.tinkerpop.gremlin.driver.ser.GraphSONMessageSerializerV1d0 by default

[WARN] AbstractGraphSONMessageSerializerV1d0 - Request [PooledUnsafeDirectByteBuf(ridx: 230, widx: 230, cap: 264)] 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]


I'm definitely running npm gremlin 3.3.3 or better

npm list gremlin

permis...@1.0.0 /Users/timothydalbey/Development/permissioner

└── gre...@3.3.3 

Globes Engagement Services

unread,
Jul 16, 2018, 2:41:09 PM7/16/18
to gremli...@googlegroups.com
Hi Tim, 

I believe this has to do with the Gremlin server not being configured to handle GraphSON v3 bytecode, you may need to look at using v3.2.9 version of gremlin, which I believe supports GraphSON v2. I might need to be corrected on that but I think that is the issue. 

Timothy Dalbey

unread,
Jul 16, 2018, 3:04:12 PM7/16/18
to Gremlin-users
The following appears to resolve the issue:

```const g = graph.traversal().withRemote(new DriverRemoteConnection('ws://localhost:8182/gremlin', { mimeType: 'application/vnd.gremlin-v2.0+json' }));```

Globes Engagement Services

unread,
Jul 16, 2018, 4:35:25 PM7/16/18
to gremli...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages