Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.
12-18-2022 02:27 AM - edited 12-19-2022 02:55 AM
Hi there, I'm using .Net 6.0 and Neo4j client 5.1.3
I've been trying to run my app in Docker. All containers are created, but when I try to send a request, my application returns the error:
Neo4j.Driver.ServiceUnavailableException: Connection with the server breaks due to ExtendedSocketException: Name or service not known 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.
Please, take a look at these configuration files. If someone knows where the issue is, please lemme know because, to tell the truth, I have no idea what is wrong here. I appreciate any help you can provide.
appsettings.json
{
"Neo4jConfiguration": {
"Uri": "bolt://neo4j:7687",
"DatabaseName": "neo4j",
"Login": "neo4j",
"Password": "6C2coi7kwnyYb7hNmfyvYNkyhxB!"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Information"
}
},
"AllowedHosts": "*"
}
docker-compose.yml
version: '3.4'
services:
server:
image: "webapi-image"
network_mode: "bridge"
ports:
- "8080:80"
build:
context: .
dockerfile: Dockerfile
stdin_open: true
tty: true
environment:
- CHOKIDAR_USEPOLLING=true
- NEO4JCONFIGURATION__URI=bolt://neo4j:7687
- NEO4JCONFIGURATION__PASSWORD=6C2coi7kwnyYb7hNmfyvYNkyhxB!
depends_on:
- neo4j
neo4j:
image: "neo4j:latest"
network_mode: "bridge"
ports:
- "7687:7687"
- "7474:7474"
volumes:
- ./neo4j/data:/data
- ./neo4j/logs:/logs
- ./neo4j/import:/var/lib/neo4j/import
- ./neo4j/plugins:/plugins
environment:
- NEO4J_AUTH=neo4j/6C2coi7kwnyYb7hNmfyvYNkyhxB!
12-18-2022 12:11 PM
What does 'neo4j' resolve to in your uri?
12-18-2022 12:24 PM
nevermind...I see 'neo4j' refers to the neo4j service on the default docker network. I am not deeply knowledgable on docker, but I got my spring boot application running in a docker container to access neo4j running in/out of a docker container, but running locally, with the following uri. It is equivalent of localhost:7687, but the host's localhost, not the container's.
bolt://host.docker.internal:7687
12-18-2022 12:26 PM
BTW- I am using a Mac. According the following article, this works on Mac and windows. An additional config is required for linux.
12-18-2022 01:08 PM
I've just tried this one)
Neo4j.Driver.ServiceUnavailableException: Connection with the server breaks due to ExtendedSocketException: Name or service not known 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.
12-18-2022 01:02 PM
The name of the container where neo4j is running.
12-18-2022 06:18 PM
Here is my docker compose.yml file:
services:
neo4j-db:
image: neo4j:4.4.11-enterprise
ports:
- 7474:7474
- 7687:7687
environment:
- NEO4J_AUTH=neo4j/test
- NEO4J_ACCEPT_LICENSE_AGREEMENT=yes
volumes:
- $HOME/neo4j/data:/data
- $HOME/neo4j/logs:/logs
- $HOME/neo4j/plugins:/plugins
- $HOME/neo4j/import:/import
healthcheck:
test: "exit 0"
item-service:
image: item-service:latest
environment:
- spring.neo4j.uri=bolt://host.docker.internal:7687
- command.line.runner.enabled=true
ports:
- 8080:8080
depends_on:
neo4j-db:
condition: service_healthy
12-20-2022 02:24 AM
I've already found the issues, to tell the truth there were several issues 🙂 Now it works, maybe it'll be useful for someone who struggle with it as well.
1. We didn't await when connect to the client and in this case we lost main exception
2. Docker compose had wrong configuration
3. When I run docker compose the app starts before the neo4j and of course we couldn't create a client because neo4j wasn't ready
```
version: '3.4'
services:
server:
image: "webapi-image"
ports:
- "8080:80"
build:
context: .
dockerfile: Dockerfile
environment:
- NEO4JCONFIGURATION__URI=bolt://neo4j:7687
- NEO4JCONFIGURATION__USERNAME=neo4j
- NEO4JCONFIGURATION__PASSWORD=6C2coi7kwnyYb7hNmfyvYNkyhxB!
depends_on:
neo4j:
condition: service_healthy
neo4j:
image: "neo4j:3.5"
ports:
- "7687:7687"
- "7474:7474"
volumes:
- ./neo4j/data:/data
- ./neo4j/logs:/logs
- ./neo4j/import:/var/lib/neo4j/import
- ./neo4j/plugins:/plugins
environment:
- NEO4J_AUTH=neo4j/6C2coi7kwnyYb7hNmfyvYNkyhxB!
healthcheck:
test: wget http://localhost:7474 || exit 1
interval: 1s
timeout: 10s
retries: 10
start_period: 3s
```
All the sessions of the conference are now available online