neo4jclient 在使用 TransactionalGraphClient 时无法对 neo4j 数据库进行身份验



以下实现 neo4jclient 的 C# 代码正确连接到数据库:

static readonly string dbConnection = "http://user:pass@localhost:7474/db/data";
GraphClient neoClient = new GraphClient(new Uri(dbConnection));

但是,当客户端转换为事务性时,相同的代码将失败。

static readonly string dbConnection = "http://user:pass@localhost:7474/db/data";
ITransactionalGraphClient neoClient = new GraphClient(new Uri(dbConnection));

有错误

The response status was: 401 Unauthorized
The response from Neo4j (which might include useful detail!) was: {
  "errors" : [ {
    "code" : "Neo.ClientError.Security.Unauthorized",
    "message" : "No authentication header supplied."
  } ]
}

我需要使用事务,这种行为是否有原因或解决方法?

更新:我发现初始数据库连接确实有效。异常是从我的第一个 Cypher 查询中抛出的,所以我也在这里发布了该查询,以防万一。

public void AddNode(NodeClass node)
{
    using (var transaction = neoClient.BeginTransaction())
    {
        var paramaters = new
        {
            Id = node.Id,
            Name = node.Name,
            ...
        };
        neoClient.Cypher
           .Create("(x:NodeLabel {paramaters})")
           .WithParam("paramaters", paramaters)
           .ExecuteWithoutResults();
        transaction.Commit();
    }
}

如果将连接更改为:

new GraphClient(new Uri("http://localhost:7474/db/data"), "user", "pass");

您将完全正确连接和执行查询。

就这种情况没有被标记为固定而言 - 这主要是因为我通常会等待错误报告者将其标记为这样,但我可能应该进行清理 - 事实上我已经去过,但还没有到达那里。

从缺少文档的 POV 来看 - 我只能再次道歉。这主要是因为不幸的是,我必须工作才能生活,有时我觉得我回家后只想放松一下:-o

最新更新