在GitHub上挂了几天了,没人理,拜托这里的大家能帮帮忙。 我开发了一个app,使用了Linux server上运行的neo4j服务。我能通过浏览器远程正常地访问7474端口,但是当使用neo4j的Java驱动时候,报错: ServiceUnavailableException: Failed to receive any data from the connected address… 我又尝试了自己的WindowsPC作为服务器(使用Neo4j 4.0.1),以及尝试了 Linux的 Neo4j 4.0.3和Neo4j 3.5.17. 都报了相同的错误。报错的就是使用driver连接的语句:driver = GraphDatabase.driver(“bolt://远程地址:7687”, AuthTokens.basic(“neo4j”,“password”)); 下面是我在GitHub上挂的求助帖。
Neo4j Version: 3.5.17 Operating System: CentOS 7 API: Java neo4j driver 1.4.4
Steps to reproduce
- Connect to Neo4j: use GraphDatabase.driver(“bolt://myaddress:7687”, AuthTokens.basic(“neo4j”,“mypassword”));
Expected behavior
Connection should be done and used normally.
Actual behavior
Failed to receive any data from the connected address.
Here is the error
org.neo4j.driver.v1.exceptions.ServiceUnavailableException: Failed to receive any data from the connected address m.y.addre.ss:7687. Please ensure a working connection to the database. at org.neo4j.driver.internal.security.TLSSocketChannel.channelRead(TLSSocketChannel.java:176) at org.neo4j.driver.internal.security.TLSSocketChannel.unwrap(TLSSocketChannel.java:235) at org.neo4j.driver.internal.security.TLSSocketChannel.read(TLSSocketChannel.java:429) at org.neo4j.driver.internal.net.SocketClient.blockingRead(SocketClient.java:77) at org.neo4j.driver.internal.net.SocketClient.negotiateProtocol(SocketClient.java:251) at org.neo4j.driver.internal.net.SocketClient.start(SocketClient.java:128) at org.neo4j.driver.internal.net.SocketConnection.startSocketClient(SocketConnection.java:92) at org.neo4j.driver.internal.net.SocketConnection.<init>(SocketConnection.java:67) at org.neo4j.driver.internal.net.SocketConnector.createConnection(SocketConnector.java:77) at org.neo4j.driver.internal.net.SocketConnector.connect(SocketConnector.java:50) at org.neo4j.driver.internal.net.pooling.SocketConnectionPool$ConnectionSupplier.get(SocketConnectionPool.java:216) at org.neo4j.driver.internal.net.pooling.SocketConnectionPool$ConnectionSupplier.get(SocketConnectionPool.java:198) at org.neo4j.driver.internal.net.pooling.BlockingPooledConnectionQueue.acquire(BlockingPooledConnectionQueue.java:96) at org.neo4j.driver.internal.net.pooling.SocketConnectionPool.acquireConnection(SocketConnectionPool.java:149) at org.neo4j.driver.internal.net.pooling.SocketConnectionPool.acquire(SocketConnectionPool.java:76) at org.neo4j.driver.internal.DirectConnectionProvider.acquireConnection(DirectConnectionProvider.java:47) at org.neo4j.driver.internal.DirectConnectionProvider.verifyConnectivity(DirectConnectionProvider.java:67) at org.neo4j.driver.internal.DirectConnectionProvider.<init>(DirectConnectionProvider.java:41) at org.neo4j.driver.internal.DriverFactory.createDirectDriver(DriverFactory.java:109) at org.neo4j.driver.internal.DriverFactory.createDriver(DriverFactory.java:93) at org.neo4j.driver.internal.DriverFactory.newInstance(DriverFactory.java:67) at org.neo4j.driver.v1.GraphDatabase.driver(GraphDatabase.java:135) at org.neo4j.driver.v1.GraphDatabase.driver(GraphDatabase.java:117) at org.neo4j.driver.v1.GraphDatabase.driver(GraphDatabase.java:92) at com.stfalcon.chatkit.sample.common.data.fixtures.MessagesFixtures.queryNeo4j(MessagesFixtures.java:134) at com.stfalcon.chatkit.sample.common.data.fixtures.MessagesFixtures.access$000(MessagesFixtures.java:23) at com.stfalcon.chatkit.sample.common.data.fixtures.MessagesFixtures$1.run(MessagesFixtures.java:66) at java.lang.Thread.run(Thread.java:929)
问题已解决,可能的确出于某些原因,java driver和neo4j之间存在着版本对应问题,我使用的是neo4j-community-3.5.17(目前官网上可以下载到的最新3.X版本),Gradle是5.6.4,在java driver上我尝试了1.0.5,1.4.4,1.5.0,1.6.1,1.7.2,4.0.0和4.0.1,其中1.0.5,1.4.4,1.5.0能build,但是在运行的时候会报Failed to receive any data from the connected address的错,1.6.1,1.7.2,4.0.0和4.0.1直接不能build,会报各种找不到类的错误。直到我偶然尝试了1.6.0版本,所有问题突然消失了,连接正常,查询也正常,bug原理完全没有头绪,希望能给各位借鉴吧,遇到类似我的问题就多尝试一下不同的驱动版本。