AWS Neptune Gremlin C#GraphTraversaSource不工作

AWS Neptune Gremlin C#GraphTraversaSource不工作,c#,gremlin,amazon-neptune,C#,Gremlin,Amazon Neptune,我已经看到很多这样做的例子(各种语言),这表明这应该是可行的。也许我错过了一步?注释掉表示我尝试过的其他事情的行 下面是我如何让我的gremlin客户端和graphTraversalSource直接使用的 var gremlinServer = new GremlinServer(endpoint, 8182, enableSsl: true); GremlinClient = new GremlinClient(gremlinServer); //var remoteConnection =

我已经看到很多这样做的例子(各种语言),这表明这应该是可行的。也许我错过了一步?注释掉表示我尝试过的其他事情的行

下面是我如何让我的gremlin客户端和graphTraversalSource直接使用的

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);
如果我以如下字符串形式提交查询:

var gndrSetCnt = GremlinQueryCount(GremlinClient, "g.V().count().next();");
var gndrResult = gndrSetCnt.Result;
var example = g.V().Count().Next();
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"}'
然后

private async Task<long> GremlinQueryCount(GremlinClient gremlinClient, string query)
{
    return await gremlinClient.SubmitWithSingleResultAsync<long>(query);
}
然后我得到一个类似这样的错误:

var gndrSetCnt = GremlinQueryCount(GremlinClient, "g.V().count().next();");
var gndrResult = gndrSetCnt.Result;
var example = g.V().Count().Next();
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"}'
我漏了一步吗?我在多个例子中看到过这一点,似乎没有做任何其他事情,但我承认,在C#中只有一个,这只是部分代码,更多的是教程。似乎没有注入别名,g只是默认可用?再次请注意,我在提交的groovy脚本中使用了g,这很有效

对于建议中的记录,我们添加了日志记录,这是示例语句生成的结果:

“RequestMessage{,requestId=709ba190-0ce9-4272-aadb-4b28c21accf6,op='bytecode',processor='traversal',args={gremlin={$type=System.Collections.Generic.Dictionary
2[[System.String,mscorlib],[System.Object,mscorlib]],mscorlib,@type=g:bytecode,@value={$type=System.Collections.Generic.Dictionary
2[[System.String,mscorlib],[System.Collections.Generic.IEnumerable
1[[System.Collections.Generic.IEnumerable
1[[System.Object,mscorlib]],mscorlib]],mscorlib,step={$type=System.Linq.Enumerable+WhereSelectListIterator
2[[Gremlin.Net.Process.Traversal.Instruction,Gremlin.Net],[System.Collections.Generic.IEnumerable
1[[System.Object,mscorlib]],mscorlib]],System.Core,$values=[[V],[hasLabel,article],[has,languageCode,fr fr],[count]}}}},别名={$type=System.Collections.Generic.Dictionary
2[[System.String,mscorlib],[System.Object,mscorlib]],mscorlib,g=g},$type=System.Collections.Generic.Dictionary
2[[System.String,mscorlib],[System.Object,mscorlib]],mscorlib}”


我不完全确定这是否有帮助。最初的错误消息表明,不知何故,该语句不是以“g”开头的,但鉴于我正在做的工作,我不明白为什么不是以“g”开头的-这是从具有“g”的drm构建gts对象作为traveral源。

您建立连接的方法是正确的,尽管现在这种方法已被弃用。您现在应该使用:

g = Traversal().withRemote(remoteConnection);

但是,这并不是导致您出现问题的原因。Neptune希望请求包含别名“g”。最好在群集上启用审核日志记录,以准确查看您的代码作为别名而不是“g”发送的内容。

感谢您的回复,我们添加了日志记录,并且已将响应添加到原始问题中。Whi您正在使用的是Gremlin.Net的ch版本吗?另外,您能否尝试一下,您是否只使用Gremlin服务器就有相同的问题?您可以从Docker开始:Docker运行--rm-p 8182:8182-it tinkerpop/Gremlin服务器。从我所看到的情况来看,您显示的代码应该可以正常工作。