使用带有用户名和密码的 gremlin-python 连接到远程 gremlin-server
Connecting to remote gremlin-server using gremlin-python with uname and password
我正在尝试连接到远程 gremlin 服务器,该服务器需要使用 gremlin_python
通过 ssl uname/password 身份验证。这是我正在使用的代码片段:
conf = yaml.load(stream, Loader=yaml.SafeLoader)
print(conf)
g = traversal().withRemote(DriverRemoteConnection(**conf))
conf字典的内容是:
{'url': 'wss://my-url.com:port', 'username': 'admin', 'password': '**', 'traversal_source': 'graph_traversal'}
我可以使用看起来像
的conf/my.properties 文件从 gremlin 控制台连接到同一台服务器
hosts: [my-url.com]
port: port
username: admin
password: *
connectionPool: { enableSsl: true }
serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}
我尝试从 python 连接的结果是 E tornado.httpclient.HTTPError: HTTP 502: Bad Gateway
。我知道我的连接 url 本身是正确的,我能够从 gremlin-console 连接并通过 https 发送脚本。我一直试图查看代码 here 以找出问题所在。
[编辑:]在更深入地研究之后,我发现您可以使用 header 中的身份验证令牌对 wss server
进行身份验证。我能够直接使用 websockets
对此进行测试。当我为 gremlin_python 打开 DriverRemoteConnection
时,有什么方法可以在 header 中传递参数?
将 {{ end_point }}
、{{ username }}
、{{ password }}
替换为您的实际值:
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 }}")
我正在尝试连接到远程 gremlin 服务器,该服务器需要使用 gremlin_python
通过 ssl uname/password 身份验证。这是我正在使用的代码片段:
conf = yaml.load(stream, Loader=yaml.SafeLoader)
print(conf)
g = traversal().withRemote(DriverRemoteConnection(**conf))
conf字典的内容是:
{'url': 'wss://my-url.com:port', 'username': 'admin', 'password': '**', 'traversal_source': 'graph_traversal'}
我可以使用看起来像
的conf/my.properties 文件从 gremlin 控制台连接到同一台服务器 hosts: [my-url.com]
port: port
username: admin
password: *
connectionPool: { enableSsl: true }
serializer: { className: org.apache.tinkerpop.gremlin.driver.ser.GryoMessageSerializerV1d0, config: { serializeResultToString: true }}
我尝试从 python 连接的结果是 E tornado.httpclient.HTTPError: HTTP 502: Bad Gateway
。我知道我的连接 url 本身是正确的,我能够从 gremlin-console 连接并通过 https 发送脚本。我一直试图查看代码 here 以找出问题所在。
[编辑:]在更深入地研究之后,我发现您可以使用 header 中的身份验证令牌对 wss server
进行身份验证。我能够直接使用 websockets
对此进行测试。当我为 gremlin_python 打开 DriverRemoteConnection
时,有什么方法可以在 header 中传递参数?
将 {{ end_point }}
、{{ username }}
、{{ password }}
替换为您的实际值:
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 }}")