3

I've seen multiple examples of this being done (various languages) which suggests this should work. Perhaps I'm missing a step? Commented out the lines that indicate other things I've tried.

Here's how I'm getting my gremlin client and also a graphTraversalSource to use directly.

var gremlinServer = new GremlinServer(endpoint, 8182, enableSsl: true);
GremlinClient = new GremlinClient(gremlinServer);

//var remoteConnection = new DriverRemoteConnection(GremlinClient, "g");
var remoteConnection = new DriverRemoteConnection(GremlinClient);
//g = AnonymousTraversalSource.Traversal().WithRemote(remoteConnection);
g = new Graph().Traversal().WithRemote(remoteConnection);

If I submit queries as strings like this:

var gndrSetCnt = GremlinQueryCount(GremlinClient, "g.V().count().next();");
var gndrResult = gndrSetCnt.Result;

and then....

private async Task<long> GremlinQueryCount(GremlinClient gremlinClient, string query)
{
    return await gremlinClient.SubmitWithSingleResultAsync<long>(query);
}

that works fine, as clumsy as it is. However, if I try to use the "g" directly, like this:

var example = g.V().Count().Next();

then I get an error like this:

Gremlin.Net.Driver.Exceptions.ResponseException: 'InvalidRequestArguments: {"detailedMessage":"A message with [bytecode] op code requires the [aliases] argument to be a Map containing one alias assignment named 'g'.","requestId":"ae024dd7-0fca-472b-acc6-7f717ca4bf2d","code":"InvalidParameterException"}'

Am I missing a step? I've seen this in multiple examples where nothing else seems to have been done, but I confess, only one in C# and that was only partial code, more of a tutorial. No aliases seem to have been injected, g just seems to be available by default? Again note I'm using g in the submitted groovy script, and that works.

For the record as per a suggestion, we added logging and this is what a sample statement produced:

"RequestMessage{, requestId=709ba190-0ce9-4272-aadb-4b28c21accf6, op='bytecode', processor='traversal', args={gremlin={$type=System.Collections.Generic.Dictionary2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib, @type=g:Bytecode, @value={$type=System.Collections.Generic.Dictionary2[[System.String, mscorlib],[System.Collections.Generic.IEnumerable1[[System.Collections.Generic.IEnumerable1[[System.Object, mscorlib]], mscorlib]], mscorlib]], mscorlib, step={$type=System.Linq.Enumerable+WhereSelectListIterator2[[Gremlin.Net.Process.Traversal.Instruction, Gremlin.Net],[System.Collections.Generic.IEnumerable1[[System.Object, mscorlib]], mscorlib]], System.Core, $values=[[V], [hasLabel, article], [has, languageCode, fr-FR], [count]]}}}, aliases={$type=System.Collections.Generic.Dictionary2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib, g=g}, $type=System.Collections.Generic.Dictionary2[[System.String, mscorlib],[System.Object, mscorlib]], mscorlib}}"

I'm not entirely sure if that's helpful. The original error message is suggesting that somehow the statement isn't starting with "g" but I don't see why it isn't, given what I'm doing - which is building a gts object from a drm which has "g" as the traveral source.

houghm
  • 31
  • 2
  • Which version of Gremlin.Net are you using? Also, can you try out whether you have the same problem with just Gremlin Server? You can start that for example with Docker: `docker run --rm -p 8182:8182 -it tinkerpop/gremlin-server`. The code you showed should work in general from what I can see. – Florian Hockmann Aug 14 '20 at 13:27

1 Answers1

0

Your method for establishing a connection is correct, albeit a now deprecated way of doing that. You should now use:

g = Traversal().withRemote(remoteConnection);

However, that is not what is causing your issue. Neptune is expecting a request that contains an alias of 'g'. It might be good to enable audit logging on your cluster to see exactly what your code is sending as the alias instead of 'g'.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Taylor Riggan
  • 1,963
  • 6
  • 12
  • Thanks for your reply, we-ve added logging and the response has been added to the original question. – houghm Aug 13 '20 at 09:07