cancel
Showing results for 
Search instead for 
Did you mean: 

Spring boot embedded neo4j: not able to connect from client when in docker container

saritatewari4
Node Link

Hello all, I upgraded one of my spring boot application from java 8 . I was using spring boot version 2.1.5.RELEASE previously with these all dependencies:

 

<maven.compiler.source>1.8</maven.compiler.source>
 <maven.compiler.target>1.8</maven.compiler.target> 
 <neo4j.version>3.5.20</neo4j.version>
 <neo4j-ogm-core.version>3.1.9</neo4j-ogm-core.version>
 <neo4j-ogm-api.version>3.1.8</neo4j-ogm-api.version>
 <neo4j-ogm-embedded-driver.version>3.1.9</neo4j-ogm-embedded-driver.version> 
 <liquigraph.version>3.1.2</liquigraph.version>
 <lombok.version>1.18.8</lombok.version>
 <spring-data-neo4j.version>5.3.1.RELEASE</spring-data-neo4j.version>
 <spring-boot-starter.version>2.1.5.RELEASE</spring-boot-starter.version>
 <spring-boot-starter-test.version>2.1.5.RELEASE</spring-boot-starter-test.version>

 

Now upgraded that to java 11 with spring boot version 2.3.3.RELEASE with these dependencies:

 

<java.version>11</java.version>
<neo4j.version>4.2.4</neo4j.version>
<neo4j-ogm-core.version>3.2.32</neo4j-ogm-core.version>
<neo4j-ogm-api.version>3.2.32</neo4j-ogm-api.version>
<liquigraph.version>4.0.2</liquigraph.version>
<lombok.version>1.18.8</lombok.version>
<spring-data-neo4j.version>5.3.3.RELEASE</spring-data-neo4j.version>
<spring-boot-starter.version>2.3.3.RELEASE</spring-boot-starter.version>
<spring-boot-starter-test.version>2.3.3.RELEASE</spring-boot-starter-test.version>

 

I am running embedded neo4j on spring-boot application. It's working fine when running in local. I am not able to connect to database from client server and I am getting this error when server is running on docker container:

Connection to the database terminated. Please ensure that your database is listening on the correct host and port and that you have compatible encryption settings both on Neo4j server and driver. Note that the default encryption setting has changed in Neo4j 4.0.

To add on , I am getting this error on neo4j desktop:

ServiceUnavailable: WebSocket connection failure. Due to security constraints in your web browser, the reason for the failure is not available to this Neo4j Driver. Please use your browsers development console to determine the root cause of the failure. Common reasons include the database being unavailable, using the wrong connection URL or temporary network problems. If you have enabled encryption, ensure your browser is configured to trust the certificate Neo4j is configured to use. WebSocket readyState is: 3

Client side this is my code snippet:

Config config = Config.builder()
                .withoutEncryption()
                .build();
driver = GraphDatabase.driver( uri, config );

and on the server side this is how I am connecting to embedded Neo4J instance: :

DatabaseManagementService managementService = new DatabaseManagementServiceBuilder(databaseDirectory.getCanonicalFile())
                .setConfig(GraphDatabaseSettings.allow_upgrade, true)
                .setConfig(GraphDatabaseSettings.default_database, neo4jProperties.getDbName())
                .setConfig(BoltConnector.encryption_level, BoltConnector.EncryptionLevel.DISABLED)
                .setConfig(BoltConnector.enabled, true)
                .setConfig(BoltConnector.listen_address,
                        new SocketAddress(neo4jProperties.getListeningAddress()))
                .build();

It was working fine with previous dependency tree with java 8 version.  Please suggest what I am missing in this configuration.

1 ACCEPTED SOLUTION

What URI are you using and what ports are you exposing in your Docker container? I suspect the 4.0 version of the database needs a change in the setup somewhere. I'm not super familiar with embedded Neo4j, but there's some more info in the docs on how to connect to that setup: https://neo4j.com/docs/java-reference/current/java-embedded/setup/. Let me know if you have more questions!

View solution in original post

2 REPLIES 2

What URI are you using and what ports are you exposing in your Docker container? I suspect the 4.0 version of the database needs a change in the setup somewhere. I'm not super familiar with embedded Neo4j, but there's some more info in the docs on how to connect to that setup: https://neo4j.com/docs/java-reference/current/java-embedded/setup/. Let me know if you have more questions!

Thanks @jennifer_reif . After adding default_listen_address=0.0.0.0 it worked.