4
votes

I am trying to connect Gephi (https://gephi.org/) and Neo4j (via docker) using Gephi's graph Streaming plugin and Neo4j's apoc procedures, as explained here: https://tbgraph.wordpress.com/2017/04/01/neo4j-to-gephi/ . I have already installed the required plugin in Gephi and the apoc procedures in neo4j, adding the required security configuration in order to allow apoc procedures to work. Therefore, neo4j.conf includes this line dbms.security.procedures.unrestricted=apoc.\*.

However, when I input the following query in the console:

MATCH path = (:Person)-[:KNOWS]->(:Person)
CALL apoc.gephi.add(null,'workspace1',path,'weight') yield nodes
return *

I get

Neo.ClientError.Procedure.ProcedureCallFailed: Failed to invoke procedure `apoc.gephi.add`: Caused by: java.net.ConnectException: Connection refused (Connection refused)

I have also tried to substitute the first null (which is the server url) with https://localhost:8443 and http://localhost:8080, but I get the same exception. Gephi Graph Streaming plugin server is listening on both 8080 and 8443. I don't know how to further troubleshoot the problem.

EDIT:

About docker, I am using a custom image with adds apoc to the base neo4j image:

# Adding APOC

FROM neo4j:3.3

ENV APOC_URI https://github.com/neo4j-contrib/neo4j-apoc-procedures/releases/download/3.3.0.1/apoc-3.3.0.1-all.jar

RUN apk add --no-cache --quiet curl

RUN mv plugins /plugins \
    && ln -s plugins /plugins

RUN curl --fail --silent --show-error --location --output apoc-3.3.0.1-all.jar $APOC_URI \
    && mv apoc-3.3.0.1-all.jar /plugins

RUN apk del curl

EXPOSE 7474 7473 7687

CMD ["neo4j"]

I run the container as:

docker run \
--publish=7474:7474 --publish=7687:7687 \
--volume=$HOME/neo4j/data:/data \
-e NEO4J_dbms_security_procedures_unrestricted=apoc.\\\* \
neo4j_apoc:3.3
1
About the only thing I could think of would be to look at the logs of Gephi. Is there anything there to check?Rebecca Nelson
Ah, you are using Docker; what do you use to execute it?Rebecca Nelson
@RebeccaNelson I have updated the question with docker informationvicaba

1 Answers

4
votes

Add --net="host" to Docker command; in the default configuration, a container's "localhost" does not point at the actual docker host.

You are trying to connect to localhost, but because of how the default Docker network (a bridge network) works, neither 127.0.0.1 nor localhost actually point to the Docker host machine, but rather point at the container itself.

It is still possible to access the Docker host, but because the Docker network is dynamic (same IPs are not guaranteed between container starts), it would require checking where the default gateway is, which would be the address to the host.

An easier fix is to just switch the network mode by passing --net="host" to the invocation of Docker:

docker run \
--publish=7474:7474 --publish=7687:7687 \
--net="host" \
--volume=$HOME/neo4j/data:/data \
-e NEO4J_dbms_security_procedures_unrestricted=apoc.\\\* \
neo4j_apoc:3.3

This will switch from bridge mode to host mode, in which the container directly uses the network stack of the host. At that point, localhost and 127.0.0.1 will both point to the Docker host (as well as the container itself).

Note that this mode has the effect of destroying the 'containerization' of the network; any ports opened up in the container will be opened on the Docker host as well.