0
votes

I am trying to connect to a remote gremlin server which requires uname/password authentication over ssl using gremlin_python. This is a snippet of the code I am using:

conf = yaml.load(stream, Loader=yaml.SafeLoader)
print(conf) 
g = traversal().withRemote(DriverRemoteConnection(**conf))

The contents of the conf dict is:

{'url': 'wss://my-url.com:port', 'username': 'admin', 'password': '**', 'traversal_source': 'graph_traversal'}

I am able to connect to the same server from gremlin console using a conf/my.properties file that looks like

  hosts: [my-url.com]
  port: port
  username: admin
  password: *
  connectionPool: { enableSsl: true }
  serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}

My attempts to connect from python is resulting in a E tornado.httpclient.HTTPError: HTTP 502: Bad Gateway. I know that my connection url itself is correct, I am able to connect from the gremlin-console as well as send scripts over https. I have been trying to look at the code here to figure out what is going wrong.

[EDIT:] After looking at this a little deeper, I figured out that you can authenticate with the wss server with an auth token in the header. I was able to test this out directly with websockets. Is there any way I can pass along a parameter in the header when I open a DriverRemoteConnection for gremlin_python?

1

1 Answers

2
votes

Replace {{ end_point }}, {{ username }}, {{ password }} as your real value:

from tornado import httpclient

my_req = httpclient.HTTPRequest('wss://{{ end_point }}:8182/gremlin', headers={"Authorization": "Token AZX ..."})

DriverRemoteConnection(my_req, 'g', username="{{ username }}", password="{{ password }}")