关闭SessionClient - AWS Neptune上的连接



我用的是aws-neptune。我试图实现我的查询事务性(与sessionClient: https://docs.aws.amazon.com/neptune/latest/userguide/access-graph-gremlin-sessions.html)。但是当我尝试实现它时,关闭客户端抛出异常。有类似的问题像我的情况:https://groups.google.com/g/janusgraph-users/c/N1TPbUU7Szw

我的代码如下:

@Bean
public Cluster gremlinCluster()
{
return Cluster.build()
.addContactPoint(GREMLIN_ENDPOINT)
.port(GREMLIN_PORT)
.enableSsl(GREMLIN_SSL_ENABLED)
.keyCertChainFile("classpath:SFSRootCAG2.pem")
.create();
}
private void runInTransaction()
{
String sessionId = UUID.randomUUID().toString();
Client.SessionedClient client = cluster.connect(sessionId);
try
{
client.submit("query...");
}
finally
{
if (client != null)
{
client.close();
}
}
}

例外是:

INFO (ConnectionPool.java:225) - Signalled closing of connection pool on Host{address=...} with core size of 1
WARN (Connection.java:322) - Timeout while trying to close connection on ... - force closing - server will close session on shutdown or expiration.
java.util.concurrent.TimeoutException
at java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1771)

有什么建议吗?

这可能是服务器的连接问题,您在发送查询时无法观察到,因为您没有等待未来完成。

当你做client.submit("query...");时,你会得到一个未来。您需要等待该future完成以观察任何异常(或成功)。

我建议如下:

  1. 尝试使用curl使用健康状态调用访问服务器以验证与服务器的连接。
  2. client.submit("query...");替换为client.submit("query...").all().join();,获取连接服务器错误信息

最新更新