orientechnologies / orientdb-gremlin

TinkerPop3 Graph Structure Implementation for OrientDB
Apache License 2.0
91 stars 32 forks source link

Connectivity from gremlin_python #160

Closed remi-sap closed 5 years ago

remi-sap commented 5 years ago

Hi, I'm trying to connect with the generic package gremlin_python. Is it possible ?

I'm using the docker image for ODB + gremlin

docker pull orientdb:3.0.17-tp3
docker run -d --name odbtp3 -p 2424:2424 -p 2480:2480 -p 8182:8182 -e ORIENTDB_ROOT_PASSWORD=rootpwd orientdb:3.0.17-tp3

Then I install package gremlin_python and I execute

from gremlin_python.process.anonymous_traversal import traversal
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection

username="root"
password="rootpwd"
database="demodb"
host="localhost"
port=8182
url="ws://"+host+":"+str(port)+"/"+database
print("Connecting to gremlin server at: ", url)

g = traversal().withRemote(
          DriverRemoteConnection(url=url, traversal_source='g', username=username, password=password))

g.V().count()

This throws an exception tornado.httpclient.HTTPError: HTTP 599: Stream closed I get the same exception if I put a wrong username, password or database name.

The failed attempts are logged:

docker logs odbtp3 2>&1 | tail
2019-03-11 11:29:54:984 WARNI SaslAuthenticationHandler only processes RequestMessage instances - received class io.netty.handler.codec.http.HttpObjectAggregator$AggregatedFullHttpRequest - channel closing [SaslAuthenticationHandler]
2019-03-11 11:30:50:159 WARNI SaslAuthenticationHandler only processes RequestMessage instances - received class io.netty.handler.codec.http.HttpObjectAggregator$AggregatedFullHttpRequest - channel closing [SaslAuthenticationHandler]

Any pointers ?

Thanks.

wolf4ood commented 5 years ago

Hi @remi-sap

from client side you cannot chose the database to use. You can only chose the traversal source in your case g which is binded to an OrientDB database configured in ${ORIENTDB_HOME}/config/gremlin-server.yaml

from gremlin_python.process.anonymous_traversal import traversal
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection

username="root"
password="rootpwd"
host="localhost"
port=8182
url="ws://"+host+":"+str(port)+"/gremlin"
print("Connecting to gremlin server at: ", url)

g = traversal().withRemote(
          DriverRemoteConnection(url=url, traversal_source='g', username=username, password=password))

g.V().count()

and also the ws url should contain gremlin

Let me know if this helps

Thanks

remi-sap commented 5 years ago

Hello, With the orientdb tinkerpop3 docker image the database is demodb.

I logged on with the studio and created a few vertices. Then the following python sample worked:

from gremlin_python.driver import client

username="root"
password="rootpwd"
host="localhost"
port=8182
url="ws://"+host+":"+str(port)+"/gremlin"
print("Connecting to gremlin server at: ", url)

g= client.Client(url=url, traversal_source='g', username=username, password=password)

query = "g.V().label()"

print(g.submit(query).next())