2
votes

I'm using the JanusGraph-Docker images (https://github.com/JanusGraph/janusgraph-docker) to set up JanusGraph in Docker. When I used JanusGraph without docker everything worked fine for me, but now I've ran into some issues:

I've used the following command to set up janusgraph with Cassandra+Elasticsearch:

docker-compose -f docker-compose-cql-es.yml up

This starts all the required containers, which I double checked with:

docker ps

Now I want to connect to Janusgraph via Gremlin console using:

docker-compose -f docker-compose-cql-es.yml run --rm -e GREMLIN_REMOTE_HOSTS=janusgraph janusgraph ./bin/gremlin.sh

This starts the gremlin console and I configure the remote with:

:remote connect tinkerpop.server conf/remote.yaml
:remote console

Which works fine aswell. After that I try to create a new graph, which fails with:

graph = JanusGraphFactory.open('conf/janusgraph-cassandra-es.properties')

This gives me the following message:

Connection refused (Connection refused)

Full Stack Trace:

java.net.ConnectException: Connection refused (Connection refused) at java.net.PlainSocketImpl.socketConnect(Native Method) at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350) at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206) at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188) at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392) at java.net.Socket.connect(Socket.java:589) at org.apache.thrift.transport.TSocket.open(TSocket.java:182) at org.apache.thrift.transport.TFramedTransport.open(TFramedTransport.java:81) at org.janusgraph.diskstorage.cassandra.thrift.thriftpool.CTConnectionFactory.makeRawConnection(CTConnectionFactory.java:110) at org.janusgraph.diskstorage.cassandra.thrift.thriftpool.CTConnectionFactory.makeObject(CTConnectionFactory.java:74) at org.janusgraph.diskstorage.cassandra.thrift.thriftpool.CTConnectionFactory.makeObject(CTConnectionFactory.java:43) at org.apache.commons.pool.impl.GenericKeyedObjectPool.borrowObject(GenericKeyedObjectPool.java:1220) at org.janusgraph.diskstorage.cassandra.thrift.CassandraThriftStoreManager.getCassandraPartitioner(CassandraThriftStoreManager.java:215) at org.janusgraph.diskstorage.cassandra.thrift.CassandraThriftStoreManager.(CassandraThriftStoreManager.java:197) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:423) at org.janusgraph.util.system.ConfigurationUtil.instantiate(ConfigurationUtil.java:58) at org.janusgraph.diskstorage.Backend.getImplementationClass(Backend.java:440) at org.janusgraph.diskstorage.Backend.getStorageManager(Backend.java:411) at org.janusgraph.graphdb.configuration.builder.GraphDatabaseConfigurationBuilder.build(GraphDatabaseConfigurationBuilder.java:50) at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:161) at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:132) at org.janusgraph.core.JanusGraphFactory.open(JanusGraphFactory.java:79) at org.janusgraph.core.JanusGraphFactory$open.call(Unknown Source) at Script4.run(Script4.groovy:1) at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:674) at org.apache.tinkerpop.gremlin.groovy.jsr223.GremlinGroovyScriptEngine.eval(GremlinGroovyScriptEngine.java:376) at javax.script.AbstractScriptEngine.eval(AbstractScriptEngine.java:233) at org.apache.tinkerpop.gremlin.groovy.engine.GremlinExecutor.lambda$eval$0(GremlinExecutor.java:266) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

I can run queries such as the following since janusgraph server seems to pre-deploy a graph with a traversal object:

g.addV('user').property('username','exampleUserName')

But when I'm trying to connect from python gremlin with:

graph = Graph()
g = graph.traversal().withRemote(DriverRemoteConnection('ws://0.0.0.0:8182/gremlin','g'))

I get the same error, any help?

1
Did you actually specify 0.0.0.0 as the IP of the host in gremlin-python? It should of course be the IP address under which the JanusGraph container can be reached. - Florian Hockmann
If i check on which IPs and Ports my containers are running it says that the janusgraph container is running on 0.0.0.0:8182->8182/tcp in gremlin-python specifying the ip like ws://0.0.0.0:8182/gremlin in the DriverRemoteConnection should be enough, right? - Robin Schmidt
Did you ever manage to fix this? I ran into the same problem and found that the cause was that the server could not connect to the elasticsearch service. The thing is that I have no idea how to fix that. - lucianopaz

1 Answers

0
votes

Note that when your server listens on 0.0.0.0, that means it will be accessible from machines other than the one that it's running on. The alternative of listening on 127.0.0.1 means it will only be accessible from processes on the same host as the server is running.

However, when your client is connecting to a server, it must specify the actual hostname or IP address it is connecting to, which could be localhost or 127.0.0.1 or whatever is the IP address that the server is connected to on the network. However, you cannot use 0.0.0.0 in the connection string from the client to the server, as that's not a valid IP address to connect to.