我一直在将.Net Core代码从Docker容器内连接到Neo4j DB。我首先尝试使用Neo4jClient,但在docker容器中遇到了http连接问题。然后,我使用host.docker.internal别名localhost的螺栓连接直接尝试了Neo4j.Driver。这很好。我用螺栓(再次从Docker内部)换回了Neo4jClient,但失败了。感谢您的帮助。
Neo4j.Driver.V1.ServiceUnavailableException
HResult=0x80131500
Message=Connection with the server breaks due to SecurityException: Failed to establish encrypted connection with server bolt://host.docker.internal:7687/.
Source=Neo4j.Driver
[Neo4j的4.x
版本要求启用加密,Neo4jClient
实际上并未提供执行此操作的简便方法,因此您需要传递IDriver
实例,如下所示:
var driver = GraphDatabase.Driver("bolt://localhost:7687", AuthTokens.Basic("neo4j", "neo"), Config.Builder.WithEncryptionLevel(EncryptionLevel.Encrypted).ToConfig());
var client = new BoltGraphClient(driver);