【问题标题】:The neo4j cypher shell and the browser connections are working but the golang client connection is not workingneo4j 密码外壳和浏览器连接正常,但 golang 客户端连接不工作
【发布时间】:2021-04-06 14:31:30
【问题描述】:

我已在我的 neo4j 服务器上禁用了身份验证,因此我可以使用密码 shell 进行连接,无需凭据,因为它遵循并正在工作。

$ ./bin/cypher-shell -a 192.168.0.89

这就是我声明驱动程序和会话的方式,我也尝试使用 neo4j://* 而不是 bolt://*:

driver, err := neo4j.NewDriver("bolt://192.168.0.89:7687", neo4j.NoAuth())
if err != nil {
    return "", err
}
defer driver.Close()

session, _ := driver.NewSession(neo4j.SessionConfig{AccessMode: neo4j.AccessModeWrite})
defer session.Close()

但这也不起作用。从 neo4j olang 驱动程序页面 https://neo4j.com/developer/go/ 运行 hello world 时出现此错误@

TLS error: Remote end closed the connection, check that TLS is enabled on the server

有服务器启动时的日志:

2021-03-07 23:17:23.227+0000 INFO  ======== Neo4j 4.2.3 ========
2021-03-07 23:17:24.119+0000 INFO  Performing postInitialization step for component 'security-users' with version 2 and status CURRENT
2021-03-07 23:17:24.119+0000 INFO  Updating the initial password in component 'security-users'  
2021-03-07 23:17:24.243+0000 INFO  Bolt enabled on 192.168.0.89:7687.
2021-03-07 23:17:25.139+0000 INFO  Remote interface available at http://192.168.0.89:7474/
2021-03-07 23:17:25.140+0000 INFO  Started.

这些都是我的配置设置:

dbms.connector.bolt.advertised_address=192.168.0.89:7687
dbms.connector.bolt.enabled=true                                                                
dbms.connector.bolt.listen_address=192.168.0.89:7687                                                                
dbms.connector.bolt.tls_level=DISABLED                                                                
dbms.connector.http.advertised_address=192.168.0.89:7474
dbms.connector.http.enabled=true                                                 
dbms.connector.http.listen_address=192.168.0.89:7474                                                               
dbms.connector.https.enabled=false                                                             
dbms.default_advertised_address=192.168.0.89
dbms.default_database=neo4j                                                               
dbms.default_listen_address=192.168.0.89                                                      
dbms.directories.import=/home/eduardo/NEO4J/import                                                       
dbms.directories.neo4j_home=/home/eduardo/NEO4J
dbms.jvm.additional=-Dlog4j2.disable.jmx=true
dbms.security.auth_enabled=false
dbms.tx_log.rotation.retention_policy=1 days                                                          
dbms.tx_state.memory_allocation=ON_HEAP
dbms.windows_service_name=neo4j

同样,我可以连接到同一主机,并且浏览器也可以正常工作: 提前感谢您的帮助:)

【问题讨论】:

    标签: neo4j cypher centos7


    【解决方案1】:

    补充您的答案:您可能正在使用 Go 驱动程序的 v1.x。如果您改用 v4.x 驱动程序,则无需指定此配置值。

    您只需在导入语句中添加v4 即可升级,如下所示:

    import github.com/neo4j/neo4j-go-driver/v4/neo4j
    

    更多信息:https://github.com/neo4j/neo4j-go-driver/blob/4.2/MIGRATIONGUIDE.md

    【讨论】:

      【解决方案2】:

      对于任何寻找答案的人,bolt 驱动程序将默认尝试使用 TLS,由于在我的情况下未配置,因此需要在驱动程序构造函数调用中禁用加密。

      driver, err := neo4j.NewDriver("bolt://192.168.0.89:7687", neo4j.NoAuth(), func(c *neo4j.Config) { c.Encrypted = false })
      

      希望这可以帮助遇到同样问题的其他人:)

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2020-11-02
        • 2011-04-21
        • 2017-02-23
        • 2021-06-28
        • 2020-10-25
        • 2022-06-27
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多