0

When I deployed my JHipster application to Heroku, and connected to a GrapheneDB Neo4J instance (version 3.5.17), the application fails to connect to the Neo4J instance. I tried to reproduce the error locally, thinking it had to do with a version mismatch, as locally the Docker version of Neo4J is 4.0.

However, I localized the error in presence/absence of credentials, with either version of Neo4J.

The working version has this docker-compose.yml file entry:

    environment:
      - NEO4J_AUTH=none

and this entry in the application.yml:

org:
  neo4j:
    driver:
      uri: bolt://localhost:7687

This version is able to connect. Once I introduce credentials, the entries look like this, docker-compose.yml:

    environment:
      - NEO4J_AUTH=myapplication/myapplication

and application.yml:

org:
  neo4j:
    driver:
      uri: bolt://localhost:7687
      authentication:
        username: myapplication
        password: myapplication

This version is unable to connect. What is the correct way to set credentials in Spring Boot as well as the neo4j docker image? Is there anything else I am missing?

Connecting to the GrapheneDB instance from my local machine gives the same error, so I suspect that the problem is in the driver configuration. Some search hits mention org.neo4j.driver.username instead of org.neo4j.driver.authentication.username but I tried both and the result is the same.

Jeroen Kransen
  • 1,379
  • 3
  • 19
  • 45

1 Answers1

2

It turns out I was misled by the Neo4J documentation, which stated that encryption was on by default. All I needed to do was:

org.neo4j.driver.config.encrypted=true

or combined, in YAML:

org:
  neo4j:
    driver:
      uri: bolt://localhost:7687
      authentication:
        username: myapplication
        password: myapplication
      config:
        encrypted: true

For full configuration, see: https://neo4j.com/developer/driver-spring-boot-starter/

Jeroen Kransen
  • 1,379
  • 3
  • 19
  • 45
  • If there’s an error in JHipster’s documentation, can you please create an issue on GitHub so we can fix it? – Matt Raible May 03 '20 at 03:00
  • Hi Matt, no it was the Neo4J documentation. I will notify them. – Jeroen Kransen May 03 '20 at 07:47
  • I have created a ticket to add it to our heroku subgen, so it will work out of box. https://github.com/jhipster/generator-jhipster/issues/11693 – atomfrede May 04 '20 at 11:45
  • By the way, according to their documentation the default value is already true, so it should work without setting it explicitly to true. – atomfrede May 04 '20 at 12:11
  • That's the documentation part that seems to be incorrect. Setting it to true explicitly solved the issue for me. So apparently it is not true by default. Awesome that you're adding it to the code generation by the way. – Jeroen Kransen May 04 '20 at 16:19