【发布时间】:2021-09-14 15:43:10
【问题描述】:
所以我使用堡垒主机/SSH 隧道从本地计算机连接到 AWS Neptune。
ssh -N -i /Users/user1/.ssh/id_rsa -L 8182:my.xxx.us-east-1.neptune.amazonaws.com:8182 user1@transporter-int.mycloud.com
我用 gremlin 做了一个简单的 Neptune 连接测试。
from gremlin_python.process.graph_traversal import __
from gremlin_python.structure.graph import Graph
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
from gremlin_python.process.traversal import T
graph = Graph()
wss = 'wss://{}:{}/gremlin'.format('localhost', 8182)
remoteConn = DriverRemoteConnection(wss, 'g')
g = graph.traversal().withRemote(remoteConn)
print(g.V().limit(2).toList())
remoteConn.close()
得到这个错误:
*aiohttp.client_exceptions.ClientConnectorCertificateError: Cannot connect to host
localhost:8182 ssl:True [SSLCertVerificationError: (1, "[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Hostname mismatch, certificate is not valid for 'localhost'. (_ssl.c:1124)")]*
根据@Taylor Riggan 的建议,我将 Mac 上的 /etc/hosts 更新为以下内容:
改用Python 3.6.12版和gremlin-python 3.4.10版
127.0.0.1 localhost my.cluster-xxx.us-east-1.neptune.amazonaws.com
运行以下命令刷新主机设置
sudo dscacheutil -flushcache
在源代码中更新了这一行
wss = 'wss://{}:{}/gremlin'.format('my.cluster-xxx.us-east-1.neptune.amazonaws.com', 8182).
现在出现以下错误,tornado 版本 4.5.3
File "/Users/user1/myproj/tests/graph/venv/lib/python3.6/site-packages/gremlin_python/driver/client.py", line 148, in submitAsync
return conn.write(message)
File "/Users/user1/myproj/tests/graph/venv/lib/python3.6/site-packages/gremlin_python/driver/connection.py", line 55, in write
self.connect()
File "/Users/user1/myproj/tests/graph/venv/lib/python3.6/site-packages/gremlin_python/driver/connection.py", line 45, in connect
self._transport.connect(self._url, self._headers)
File "/Users/user1/myproj/tests/graph/venv/lib/python3.6/site-packages/gremlin_python/driver/tornado/transport.py", line 41, in connect
lambda: websocket.websocket_connect(url, compression_options=self._compression_options))
File "/Users/user1/myproj/tests/graph/venv/lib/python3.6/site-packages/tornado/ioloop.py", line 576, in run_sync
return future_cell[0].result()
tornado.httpclient.HTTPClientError: HTTP 403: Forbidden
【问题讨论】:
标签: python amazon-web-services ssl gremlin amazon-neptune