刚刚尝试了下面提到的代码来检查我的Amazon Neptune服务,它抛出了这个错误:
ClientConnectorError: Cannot connect to host <host>:8182 ssl:default [Connect call failed ('<ip-address>', 8182)]
from __future__ import print_function # Python 2/3 compatibility
from gremlin_python import statics
from gremlin_python.structure.graph import Graph
from gremlin_python.process.graph_traversal import __
from gremlin_python.process.strategies import *
from gremlin_python.driver.driver_remote_connection import DriverRemoteConnection
graph = Graph()
remoteConn = DriverRemoteConnection('wss://<host>','g')
g = graph.traversal().withRemote(remoteConn)
print(g.V().limit(2).toList())
remoteConn.close()
有人知道答案吗?由于
<host>
是一个占位符,您需要将其替换为运行Gremlin Server的主机名。如果您的python客户端运行在同一台主机上,您可以将<host>
替换为localhost
。
还请注意,如果在Gremlin服务器上配置了安全套接字层,则只能使用以wss://开头的url,否则使用以ws://开头的url。
请记住,当您在本地连接时,您应该跳到堡垒主机,并在本地更改Neptune DNS以指向本地,例如
127.0.0.1 neptune.dns.aws.com
当您连接到AWS网络时,您可以调用curl命令来获取海王星的响应。
curl -X POST --data-binary 'query=select ?s ?p ?o where {?s ?p ?o} limit 10' http://neptune-dns.neptune.amazonaws.com:8182/sparql
假设您有一个业务连接到同一个VPC中,或者在一个可以与海王星DB所在VPC通信的VPC中。需要连接到海王星数据库的服务需要能够访问海王星数据库的安全组例如,在Neptune_DB的安全组中添加入站规则,允许来自服务的安全组的所有流量,或至少TCP(如wss://使用TCP)。