Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Neo4j bolt driver protocol error

Tags:

neo4j

I am getting below error while trying neo4j bolt driver to run simple cypher. Any idea what is going wrong?

    public void boltDriver() {
    Config noSSL = Config.build()
            .withEncryptionLevel(Config.EncryptionLevel.NONE).toConfig();
    Driver driver = GraphDatabase.driver("bolt://localhost:7474",
            AuthTokens.basic("neo4j", "neo4j1"), noSSL); // <password>

    try (Session session = driver.session()) {

        StatementResult result;

        String foafQuery = " MATCH (n) WHERE EXISTS(n.country) RETURN DISTINCT \"node\" as element, n.country AS country ";
        result = session.run(foafQuery, parameters("name", "Joe"));
        while (result.hasNext()) {
            Record next = result.next();
            System.out.println(next.get("element"));
            System.out.println(next.get("country"));
        }

    }

}

Exception: Exception in thread "main" org.neo4j.driver.v1.exceptions.ClientException: Protocol error, server suggested unexpected protocol version: 1213486160 at org.neo4j.driver.internal.connector.socket.SocketClient.negotiateProtocol(SocketClient.java:198) at org.neo4j.driver.internal.connector.socket.SocketClient.start(SocketClient.java:73) at org.neo4j.driver.internal.connector.socket.SocketConnection.(SocketConnection.java:63) at org.neo4j.driver.internal.connector.socket.SocketConnector.connect(SocketConnector.java:52) at org.neo4j.driver.internal.pool.InternalConnectionPool$1.allocate(InternalConnectionPool.java:191) at org.neo4j.driver.internal.pool.InternalConnectionPool$1.allocate(InternalConnectionPool.java:180) at org.neo4j.driver.internal.pool.ThreadCachingPool.allocate(ThreadCachingPool.java:212) at org.neo4j.driver.internal.pool.ThreadCachingPool.acquireFromGlobal(ThreadCachingPool.java:164) at org.neo4j.driver.internal.pool.ThreadCachingPool.acquire(ThreadCachingPool.java:118) at org.neo4j.driver.internal.pool.InternalConnectionPool.acquire(InternalConnectionPool.java:109) at org.neo4j.driver.internal.InternalDriver.session(InternalDriver.java:53) at Neo4jMain.boldDriver(Neo4jMain.java:55) at Neo4jMain.main(Neo4jMain.java:30)

like image 578
N R Avatar asked May 10 '16 03:05

N R


2 Answers

You're using the wrong port number. 7474 is by default used for http whereas 7687 is the default for binary bolt protocol.

like image 194
Stefan Armbruster Avatar answered Nov 16 '22 13:11

Stefan Armbruster


An important hint is that 1213486160 is "HTTP" as a 32-bit big-endian number.

like image 1
Joe Oswald Avatar answered Nov 16 '22 12:11

Joe Oswald